Skip to content

Commit 52ade74

Browse files
committed
enhance: git commit message keyword must starts from begining of a line
Signed-off-by: leo <longshuang@msn.cn>
1 parent a744a93 commit 52ade74

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

src/Views/CommitMessageToolBox.axaml.cs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -232,8 +232,15 @@ protected override void OnTextChanged(EventArgs e)
232232

233233
var caretOffset = CaretOffset;
234234
var start = caretOffset;
235-
while (start > 0 && !char.IsWhiteSpace(Text[start - 1]))
236-
start--;
235+
for (; start > 0; start--)
236+
{
237+
var ch = Text[start - 1];
238+
if (ch == '\n')
239+
break;
240+
241+
if (!char.IsAscii(ch))
242+
return;
243+
}
237244

238245
if (caretOffset == start)
239246
{
@@ -316,7 +323,7 @@ private void OnTextViewVisualLinesChanged(object sender, EventArgs e)
316323
InvalidateVisual();
317324
}
318325

319-
private readonly List<string> _keywords = ["git", "GitHub", "GitLab", "Acked-by: ", "Co-authored-by: ", "Reviewed-by: ", "Signed-off-by: ", "BREAKING CHANGE: "];
326+
private readonly List<string> _keywords = ["Acked-by: ", "Co-authored-by: ", "Reviewed-by: ", "Signed-off-by: ", "BREAKING CHANGE: "];
320327
private bool _isEditing = false;
321328
private CompletionWindow _completionWnd = null;
322329
}

0 commit comments

Comments
 (0)