Browse Source

Fixed ArgumentException in TextView.Redraw when deleting line in XML document.

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@5766 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
pull/1/head
Daniel Grunwald 15 years ago
parent
commit
b1098071ce
  1. 21
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Highlighting/DocumentHighlighter.cs
  2. 2
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Highlighting/HighlightingColorizer.cs

21
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Highlighting/DocumentHighlighter.cs

@ -179,7 +179,7 @@ namespace ICSharpCode.AvalonEdit.Highlighting @@ -179,7 +179,7 @@ namespace ICSharpCode.AvalonEdit.Highlighting
//Debug.WriteLine("Highlight line " + lineNumber + (highlightedLine != null ? "" : " (span stack only)"));
spanStack = storedSpanStacks[lineNumber - 1];
HighlightLineInternal(line);
if (storedSpanStacks[lineNumber] != spanStack) {
if (!EqualSpanStacks(spanStack, storedSpanStacks[lineNumber])) {
isValid[lineNumber] = true;
//Debug.WriteLine("Span stack in line " + lineNumber + " changed from " + storedSpanStacks[lineNumber] + " to " + spanStack);
storedSpanStacks[lineNumber] = spanStack;
@ -198,6 +198,25 @@ namespace ICSharpCode.AvalonEdit.Highlighting @@ -198,6 +198,25 @@ namespace ICSharpCode.AvalonEdit.Highlighting
}
}
static bool EqualSpanStacks(SpanStack a, SpanStack b)
{
// We must use value equality between the stacks because TextViewDocumentHighlighter.OnHighlightStateChanged
// depends on the fact that equal input state + unchanged line contents produce equal output state.
if (a == b)
return true;
if (a == null || b == null)
return false;
while (!a.IsEmpty && !b.IsEmpty) {
if (a.Peek() != b.Peek())
return false;
a = a.Pop();
b = b.Pop();
if (a == b)
return true;
}
return a.IsEmpty && b.IsEmpty;
}
/// <summary>
/// Is called when the highlighting state at the end of the specified line has changed.
/// </summary>

2
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Highlighting/HighlightingColorizer.cs

@ -218,7 +218,7 @@ namespace ICSharpCode.AvalonEdit.Highlighting @@ -218,7 +218,7 @@ namespace ICSharpCode.AvalonEdit.Highlighting
// We'll prove that: if line N is being reused, then the highlighting state is up-to-date until (end of) line N-1.
// Start of induction: the first line in view can is reused only if the highlighting state was up-to-date
// Start of induction: the first line in view is reused only if the highlighting state was up-to-date
// until line N-1 (no change detected in VisualLineConstructionStarting event).
// Induction step:

Loading…
Cancel
Save