|
|
|
|
@ -385,8 +385,29 @@ namespace ICSharpCode.AvalonEdit.Editing
@@ -385,8 +385,29 @@ namespace ICSharpCode.AvalonEdit.Editing
|
|
|
|
|
if (!object.Equals(selection, value)) { |
|
|
|
|
Debug.WriteLine("Selection change from " + selection + " to " + value); |
|
|
|
|
if (textView != null) { |
|
|
|
|
textView.Redraw(selection.SurroundingSegment, DispatcherPriority.Background); |
|
|
|
|
textView.Redraw(value.SurroundingSegment, DispatcherPriority.Background); |
|
|
|
|
ISegment oldSegment = selection.SurroundingSegment; |
|
|
|
|
ISegment newSegment = value.SurroundingSegment; |
|
|
|
|
if (selection is SimpleSelection && value is SimpleSelection && oldSegment != null && newSegment != null) { |
|
|
|
|
// perf optimization:
|
|
|
|
|
// When a simple selection changes, don't redraw the whole selection, but only the changed parts.
|
|
|
|
|
int oldSegmentOffset = oldSegment.Offset; |
|
|
|
|
int newSegmentOffset = newSegment.Offset; |
|
|
|
|
if (oldSegmentOffset != newSegmentOffset) { |
|
|
|
|
textView.Redraw(Math.Min(oldSegmentOffset, newSegmentOffset), |
|
|
|
|
Math.Abs(oldSegmentOffset - newSegmentOffset), |
|
|
|
|
DispatcherPriority.Background); |
|
|
|
|
} |
|
|
|
|
int oldSegmentEndOffset = oldSegment.EndOffset; |
|
|
|
|
int newSegmentEndOffset = newSegment.EndOffset; |
|
|
|
|
if (oldSegmentEndOffset != newSegmentEndOffset) { |
|
|
|
|
textView.Redraw(Math.Min(oldSegmentEndOffset, newSegmentEndOffset), |
|
|
|
|
Math.Abs(oldSegmentEndOffset - newSegmentEndOffset), |
|
|
|
|
DispatcherPriority.Background); |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
textView.Redraw(oldSegment, DispatcherPriority.Background); |
|
|
|
|
textView.Redraw(newSegment, DispatcherPriority.Background); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
selection = value; |
|
|
|
|
if (SelectionChanged != null) |
|
|
|
|
|