Highlighter resumes from last unchanged line's state

This allows for new a new line inserted inside a comment to be
highlighted correctly, for example.
This commit is contained in:
Nathan Sobo
2012-02-03 11:19:43 -07:00
parent 2b6b4b1717
commit 94f7296999
2 changed files with 16 additions and 8 deletions

View File

@@ -20,8 +20,9 @@ class Highlighter
postRange = e.postRange.copy()
previousState = @lines[preRange.end.row].state
newLines = @tokenizeRows('start', postRange.start.row, postRange.end.row)
@lines[preRange.start.row..preRange.end.row] = newLines
startState = @lines[postRange.start.row - 1]?.state or 'start'
@lines[preRange.start.row..preRange.end.row] =
@tokenizeRows(startState, postRange.start.row, postRange.end.row)
for row in [postRange.end.row...@buffer.lastRow()]
break if @lines[row].state == previousState