diff --git a/src/Converters/IntConverters.cs b/src/Converters/IntConverters.cs index 6bfee48d..64f9b357 100644 --- a/src/Converters/IntConverters.cs +++ b/src/Converters/IntConverters.cs @@ -19,7 +19,10 @@ namespace SourceGit.Converters public static readonly FuncValueConverter IsNotOne = new FuncValueConverter(v => v != 1); - public static readonly FuncValueConverter IsBadSubjectLength = + public static readonly FuncValueConverter IsSubjectLengthBad = new FuncValueConverter(v => v > ViewModels.Preference.Instance.SubjectGuideLength); + + public static readonly FuncValueConverter IsSubjectLengthGood = + new FuncValueConverter(v => v <= ViewModels.Preference.Instance.SubjectGuideLength); } } diff --git a/src/Views/CommitMessageTextBox.axaml b/src/Views/CommitMessageTextBox.axaml index 1fda8da8..e273b71d 100644 --- a/src/Views/CommitMessageTextBox.axaml +++ b/src/Views/CommitMessageTextBox.axaml @@ -42,15 +42,19 @@ - + + + + - - - - - - + + + + + + + diff --git a/src/Views/CommitMessageTextBox.axaml.cs b/src/Views/CommitMessageTextBox.axaml.cs index d7b2e8a6..432e2fb4 100644 --- a/src/Views/CommitMessageTextBox.axaml.cs +++ b/src/Views/CommitMessageTextBox.axaml.cs @@ -31,7 +31,6 @@ namespace SourceGit.Views public TextDocument Document { get; - private set; } public CommitMessageTextBox() @@ -44,11 +43,8 @@ namespace SourceGit.Views { base.OnPropertyChanged(change); - if (change.Property == TextProperty) - { - if (!_isDocumentTextChanging) + if (change.Property == TextProperty && !_isDocumentTextChanging) Document.Text = Text; - } } private void OnTextEditorLayoutUpdated(object sender, EventArgs e) @@ -85,23 +81,18 @@ namespace SourceGit.Views SetCurrentValue(TextProperty, Document.Text); _isDocumentTextChanging = false; - var setSubject = false; - for (int i = 0; i < Document.LineCount; i++) + for (var i = 0; i < Document.LineCount; i++) { var line = Document.Lines[i]; if (line.LineNumber > 1 && line.Length == 0) { - var subject = Text.Substring(0, line.Offset).ReplaceLineEndings(" ").Trim(); + var subject = Text[..line.Offset].ReplaceLineEndings(" ").Trim(); SetCurrentValue(SubjectLengthProperty, subject.Length); - setSubject = true; - break; + return; } _subjectEndLineNumber = line.LineNumber; } - - if (setSubject) - return; SetCurrentValue(SubjectLengthProperty, Text.ReplaceLineEndings(" ").Trim().Length); }