mirror of
https://github.com/sourcegit-scm/sourcegit.git
synced 2024-12-25 21:07:20 -08:00
refactor: remove Caret.PositionChanged
event listener since TextArea.LayoutUpdated
will also triggered when caret position changed (#448)
This commit is contained in:
parent
4be7710336
commit
acd6171350
1 changed files with 8 additions and 9 deletions
|
@ -234,7 +234,6 @@ namespace SourceGit.Views
|
||||||
TextArea.LeftMargins.Add(new CommitInfoMargin(this) { Margin = new Thickness(8, 0) });
|
TextArea.LeftMargins.Add(new CommitInfoMargin(this) { Margin = new Thickness(8, 0) });
|
||||||
TextArea.LeftMargins.Add(new VerticalSeperatorMargin(this));
|
TextArea.LeftMargins.Add(new VerticalSeperatorMargin(this));
|
||||||
TextArea.LayoutUpdated += OnTextAreaLayoutUpdated;
|
TextArea.LayoutUpdated += OnTextAreaLayoutUpdated;
|
||||||
TextArea.Caret.PositionChanged += OnCaretPositionChanged;
|
|
||||||
TextArea.TextView.ContextRequested += OnTextViewContextRequested;
|
TextArea.TextView.ContextRequested += OnTextViewContextRequested;
|
||||||
TextArea.TextView.VisualLinesChanged += OnTextViewVisualLinesChanged;
|
TextArea.TextView.VisualLinesChanged += OnTextViewVisualLinesChanged;
|
||||||
TextArea.TextView.Margin = new Thickness(4, 0);
|
TextArea.TextView.Margin = new Thickness(4, 0);
|
||||||
|
@ -279,8 +278,7 @@ namespace SourceGit.Views
|
||||||
base.OnUnloaded(e);
|
base.OnUnloaded(e);
|
||||||
|
|
||||||
TextArea.LeftMargins.Clear();
|
TextArea.LeftMargins.Clear();
|
||||||
TextArea.LayoutUpdated += OnTextAreaLayoutUpdated;
|
TextArea.LayoutUpdated -= OnTextAreaLayoutUpdated;
|
||||||
TextArea.Caret.PositionChanged -= OnCaretPositionChanged;
|
|
||||||
TextArea.TextView.ContextRequested -= OnTextViewContextRequested;
|
TextArea.TextView.ContextRequested -= OnTextViewContextRequested;
|
||||||
TextArea.TextView.VisualLinesChanged -= OnTextViewVisualLinesChanged;
|
TextArea.TextView.VisualLinesChanged -= OnTextViewVisualLinesChanged;
|
||||||
|
|
||||||
|
@ -314,17 +312,12 @@ namespace SourceGit.Views
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnTextAreaLayoutUpdated(object sender, EventArgs e)
|
private void OnTextAreaLayoutUpdated(object sender, EventArgs e)
|
||||||
{
|
|
||||||
InvalidateVisual();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void OnCaretPositionChanged(object sender, EventArgs e)
|
|
||||||
{
|
{
|
||||||
if (!TextArea.IsFocused)
|
if (!TextArea.IsFocused)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var caret = TextArea.Caret;
|
var caret = TextArea.Caret;
|
||||||
if (caret.Line >= BlameData.LineInfos.Count)
|
if (caret == null || caret.Line >= BlameData.LineInfos.Count)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var info = BlameData.LineInfos[caret.Line - 1];
|
var info = BlameData.LineInfos[caret.Line - 1];
|
||||||
|
@ -332,7 +325,12 @@ namespace SourceGit.Views
|
||||||
{
|
{
|
||||||
_highlight = info.CommitSHA;
|
_highlight = info.CommitSHA;
|
||||||
InvalidateVisual();
|
InvalidateVisual();
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var offset = TextArea.TextView.VerticalOffset;
|
||||||
|
if (_lastOffsetY != offset)
|
||||||
|
InvalidateVisual();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnTextViewContextRequested(object sender, ContextRequestedEventArgs e)
|
private void OnTextViewContextRequested(object sender, ContextRequestedEventArgs e)
|
||||||
|
@ -380,6 +378,7 @@ namespace SourceGit.Views
|
||||||
|
|
||||||
private TextMate.Installation _textMate = null;
|
private TextMate.Installation _textMate = null;
|
||||||
private string _highlight = string.Empty;
|
private string _highlight = string.Empty;
|
||||||
|
private double _lastOffsetY = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public partial class Blame : ChromelessWindow
|
public partial class Blame : ChromelessWindow
|
||||||
|
|
Loading…
Reference in a new issue