Skip to content

Commit 63b30b7

Browse files
committed
DocumentHighlighter.InvalidateHighlighting() should cause a textview redraw. (#16)
1 parent c84c93b commit 63b30b7

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

ICSharpCode.AvalonEdit/Highlighting/DocumentHighlighter.cs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public DocumentHighlighter(TextDocument document, IHighlightingDefinition defini
6969
this.engine = new HighlightingEngine(definition.MainRuleSet);
7070
document.VerifyAccess();
7171
weakLineTracker = WeakLineTracker.Register(document, this);
72-
InvalidateHighlighting();
72+
InvalidateSpanStacks();
7373
}
7474

7575
#if NREFACTORY
@@ -134,7 +134,7 @@ void ILineTracker.LineInserted(DocumentLine insertionPos, DocumentLine newLine)
134134

135135
void ILineTracker.RebuildDocument()
136136
{
137-
InvalidateHighlighting();
137+
InvalidateSpanStacks();
138138
}
139139

140140
void ILineTracker.ChangeComplete(DocumentChangeEventArgs e)
@@ -160,6 +160,15 @@ public ImmutableStack<HighlightingSpan> InitialSpanStack {
160160
/// needs to be called only when there are changes to the highlighting rule set.
161161
/// </summary>
162162
public void InvalidateHighlighting()
163+
{
164+
InvalidateSpanStacks();
165+
OnHighlightStateChanged(1, document.LineCount); // force a redraw with the new highlighting
166+
}
167+
168+
/// <summary>
169+
/// Invalidates stored highlighting info, but does not raise the HighlightingStateChanged event.
170+
/// </summary>
171+
void InvalidateSpanStacks()
163172
{
164173
CheckIsHighlighting();
165174
storedSpanStacks.Clear();

0 commit comments

Comments
 (0)