mirror of
https://github.com/sourcegit-scm/sourcegit.git
synced 2024-12-24 20:57:19 -08:00
enhance: only re-calculate highlight chunk when it is needed
This commit is contained in:
parent
e945367b28
commit
d5671ea8df
1 changed files with 35 additions and 25 deletions
|
@ -437,8 +437,8 @@ namespace SourceGit.Views
|
||||||
base.OnLoaded(e);
|
base.OnLoaded(e);
|
||||||
|
|
||||||
TextArea.TextView.ContextRequested += OnTextViewContextRequested;
|
TextArea.TextView.ContextRequested += OnTextViewContextRequested;
|
||||||
TextArea.TextView.PointerEntered += OnTextViewPointerEntered;
|
TextArea.TextView.PointerEntered += OnTextViewPointerChanged;
|
||||||
TextArea.TextView.PointerMoved += OnTextViewPointerMoved;
|
TextArea.TextView.PointerMoved += OnTextViewPointerChanged;
|
||||||
TextArea.TextView.PointerWheelChanged += OnTextViewPointerWheelChanged;
|
TextArea.TextView.PointerWheelChanged += OnTextViewPointerWheelChanged;
|
||||||
|
|
||||||
UpdateTextMate();
|
UpdateTextMate();
|
||||||
|
@ -449,8 +449,8 @@ namespace SourceGit.Views
|
||||||
base.OnUnloaded(e);
|
base.OnUnloaded(e);
|
||||||
|
|
||||||
TextArea.TextView.ContextRequested -= OnTextViewContextRequested;
|
TextArea.TextView.ContextRequested -= OnTextViewContextRequested;
|
||||||
TextArea.TextView.PointerEntered -= OnTextViewPointerEntered;
|
TextArea.TextView.PointerEntered -= OnTextViewPointerChanged;
|
||||||
TextArea.TextView.PointerMoved -= OnTextViewPointerMoved;
|
TextArea.TextView.PointerMoved -= OnTextViewPointerChanged;
|
||||||
TextArea.TextView.PointerWheelChanged -= OnTextViewPointerWheelChanged;
|
TextArea.TextView.PointerWheelChanged -= OnTextViewPointerWheelChanged;
|
||||||
|
|
||||||
if (_textMate != null)
|
if (_textMate != null)
|
||||||
|
@ -510,35 +510,43 @@ namespace SourceGit.Views
|
||||||
e.Handled = true;
|
e.Handled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnTextViewPointerEntered(object sender, PointerEventArgs e)
|
private void OnTextViewPointerChanged(object sender, PointerEventArgs e)
|
||||||
{
|
{
|
||||||
if (EnableChunkSelection && sender is TextView view)
|
if (EnableChunkSelection && sender is TextView view)
|
||||||
{
|
{
|
||||||
var chunk = SelectedChunk;
|
var selection = TextArea.Selection;
|
||||||
if (chunk != null)
|
if (selection == null || selection.IsEmpty)
|
||||||
{
|
{
|
||||||
var rect = new Rect(0, chunk.Y, Bounds.Width, chunk.Height);
|
if (_lastSelectStart != _lastSelectEnd)
|
||||||
if (rect.Contains(e.GetPosition(this)))
|
{
|
||||||
return;
|
_lastSelectStart = TextLocation.Empty;
|
||||||
|
_lastSelectEnd = TextLocation.Empty;
|
||||||
|
}
|
||||||
|
|
||||||
|
var chunk = SelectedChunk;
|
||||||
|
if (chunk != null)
|
||||||
|
{
|
||||||
|
var rect = new Rect(0, chunk.Y, Bounds.Width, chunk.Height);
|
||||||
|
if (rect.Contains(e.GetPosition(this)))
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
UpdateSelectedChunk(e.GetPosition(view).Y + view.VerticalOffset);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
UpdateSelectedChunk(e.GetPosition(view).Y + view.VerticalOffset);
|
var start = selection.StartPosition.Location;
|
||||||
}
|
var end = selection.EndPosition.Location;
|
||||||
}
|
if (_lastSelectStart != start || _lastSelectEnd != end)
|
||||||
|
|
||||||
private void OnTextViewPointerMoved(object sender, PointerEventArgs e)
|
|
||||||
{
|
|
||||||
if (EnableChunkSelection && sender is TextView view)
|
|
||||||
{
|
|
||||||
var chunk = SelectedChunk;
|
|
||||||
if (chunk != null)
|
|
||||||
{
|
{
|
||||||
var rect = new Rect(0, chunk.Y, Bounds.Width, chunk.Height);
|
_lastSelectStart = start;
|
||||||
if (rect.Contains(e.GetPosition(this)))
|
_lastSelectEnd = end;
|
||||||
return;
|
UpdateSelectedChunk(e.GetPosition(view).Y + view.VerticalOffset);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
UpdateSelectedChunk(e.GetPosition(view).Y + view.VerticalOffset);
|
if (SelectedChunk == null)
|
||||||
|
UpdateSelectedChunk(e.GetPosition(view).Y + view.VerticalOffset);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -657,7 +665,9 @@ namespace SourceGit.Views
|
||||||
}
|
}
|
||||||
|
|
||||||
private TextMate.Installation _textMate = null;
|
private TextMate.Installation _textMate = null;
|
||||||
protected LineStyleTransformer _lineStyleTransformer = null;
|
private TextLocation _lastSelectStart = TextLocation.Empty;
|
||||||
|
private TextLocation _lastSelectEnd = TextLocation.Empty;
|
||||||
|
private LineStyleTransformer _lineStyleTransformer = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public class CombinedTextDiffPresenter : ThemedTextDiffPresenter
|
public class CombinedTextDiffPresenter : ThemedTextDiffPresenter
|
||||||
|
|
Loading…
Reference in a new issue