private void TextView_VisualLineConstructionStarting(object sender, VisualLineConstructionStartEventArgs e) { if (_highlighter != null) { // Force update of highlighting state up to the position where we start generating visual lines. // This is necessary in case the document gets modified above the FirstLineInView so that the highlighting state changes. // We need to detect this case and issue a redraw (through OnHighlightStateChanged) // before the visual line construction reuses existing lines that were built using the invalid highlighting state. _lineNumberBeingColorized = e.FirstLineInView.LineNumber - 1; if (!_isInHighlightingGroup) { // avoid opening group twice if there was an exception during the previous visual line construction // (not ideal, but better than throwing InvalidOperationException "group already open" // without any way of recovering) _highlighter.BeginHighlighting(); _isInHighlightingGroup = true; } _highlighter.UpdateHighlightingState(_lineNumberBeingColorized); _lineNumberBeingColorized = 0; } }
public void UpdateHighlightingState(int lineNumber) { baseHighlighter.UpdateHighlightingState(lineNumber); }