Improve highlither for document edits
The syntax highlighter keep a cache of the documents like tokenization. In order to minimize the amount of tokenize re-computations we insert some emtty lines or remove some lines in the highlither lines corresponding to the lines added or removed to the document.
This commit is contained in:
@@ -349,7 +349,7 @@ function Doc:raw_insert(line, col, text, undo_stack, time)
|
||||
push_undo(undo_stack, time, "remove", line, col, line2, col2)
|
||||
|
||||
-- update highlighter and assure selection is in bounds
|
||||
self.highlighter:invalidate(line)
|
||||
self.highlighter:insert_notify(line, #lines - 1)
|
||||
self:sanitize_selection()
|
||||
end
|
||||
|
||||
@@ -376,7 +376,7 @@ function Doc:raw_remove(line1, col1, line2, col2, undo_stack, time)
|
||||
end
|
||||
|
||||
-- update highlighter and assure selection is in bounds
|
||||
self.highlighter:invalidate(line1)
|
||||
self.highlighter:remove_notify(line1, line2 - line1)
|
||||
self:sanitize_selection()
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user