Skip to content

Commit

Permalink
Improve DiffViewModel update performance by checking for an overlap w…
Browse files Browse the repository at this point in the history
…ith the view's FormattedSpan
  • Loading branch information
sharwell committed Mar 19, 2013
1 parent 17a252a commit d2440fb
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions Diff/ViewModel/DiffViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,25 @@ private void UpdateDimensions(bool approximate, TextViewLayoutChangedEventArgs e
ITextSnapshotLine endLine = _textView.TextSnapshot.GetLineFromLineNumber(endLineNumber);
if (startLine != null && endLine != null)
{
if (endLine.LineNumber < startLine.LineNumber)
{
SnapshotSpan span = new SnapshotSpan(endLine.Start, startLine.End);
if (!_textView.TextViewLines.FormattedSpan.IntersectsWith(span))
{
IsVisible = false;
return;
}
}
else
{
SnapshotSpan span = new SnapshotSpan(startLine.Start, endLine.End);
if (!_textView.TextViewLines.FormattedSpan.IntersectsWith(span))
{
IsVisible = false;
return;
}
}

IWpfTextViewLine startLineView = _textView.GetTextViewLineContainingBufferPosition(startLine.Start);
IWpfTextViewLine endLineView = _textView.GetTextViewLineContainingBufferPosition(endLine.Start);
if (startLineView == null || endLineView == null)
Expand Down

0 comments on commit d2440fb

Please sign in to comment.