From f5b8bc472a3634e1c1d6ec4a03a840ebc3998dd3 Mon Sep 17 00:00:00 2001 From: leo Date: Tue, 10 Sep 2024 12:03:07 +0800 Subject: [PATCH] fix: hightlight not working the first time clicking the first line (#448) --- src/Views/Blame.axaml.cs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/Views/Blame.axaml.cs b/src/Views/Blame.axaml.cs index ddd001dd..68e14de5 100644 --- a/src/Views/Blame.axaml.cs +++ b/src/Views/Blame.axaml.cs @@ -233,6 +233,7 @@ namespace SourceGit.Views TextArea.LeftMargins.Add(new VerticalSeperatorMargin(this)); TextArea.LeftMargins.Add(new CommitInfoMargin(this) { Margin = new Thickness(8, 0) }); TextArea.LeftMargins.Add(new VerticalSeperatorMargin(this)); + TextArea.Caret.PositionChanged += OnTextAreaCaretPositionChanged; TextArea.LayoutUpdated += OnTextAreaLayoutUpdated; TextArea.PointerWheelChanged += OnTextAreaPointerWheelChanged; TextArea.TextView.ContextRequested += OnTextViewContextRequested; @@ -279,7 +280,9 @@ namespace SourceGit.Views base.OnUnloaded(e); TextArea.LeftMargins.Clear(); + TextArea.Caret.PositionChanged -= OnTextAreaCaretPositionChanged; TextArea.LayoutUpdated -= OnTextAreaLayoutUpdated; + TextArea.PointerWheelChanged -= OnTextAreaPointerWheelChanged; TextArea.TextView.ContextRequested -= OnTextViewContextRequested; TextArea.TextView.VisualLinesChanged -= OnTextViewVisualLinesChanged; @@ -312,7 +315,7 @@ namespace SourceGit.Views } } - private void OnTextAreaLayoutUpdated(object sender, EventArgs e) + private void OnTextAreaCaretPositionChanged(object sender, EventArgs e) { if (!TextArea.IsFocused) return; @@ -325,6 +328,12 @@ namespace SourceGit.Views InvalidateVisual(); } + private void OnTextAreaLayoutUpdated(object sender, EventArgs e) + { + if (TextArea.IsFocused) + InvalidateVisual(); + } + private void OnTextAreaPointerWheelChanged(object sender, PointerWheelEventArgs e) { if (!TextArea.IsFocused && !string.IsNullOrEmpty(_highlight))