Fixed highlighter resetting of syntax on doc filename change
This commit is contained in:
parent
70f62f3c8a
commit
3d49b6d200
|
@ -9,9 +9,7 @@ local Highlighter = Object:extend()
|
|||
|
||||
function Highlighter:new(doc)
|
||||
self.doc = doc
|
||||
self.lines = {}
|
||||
self.first_invalid_line = 1
|
||||
self.max_wanted_line = 0
|
||||
self:reset()
|
||||
|
||||
-- init incremental syntax highlighting
|
||||
core.add_thread(function()
|
||||
|
@ -40,6 +38,12 @@ function Highlighter:new(doc)
|
|||
end
|
||||
|
||||
|
||||
function Highlighter:reset()
|
||||
self.lines = {}
|
||||
self.first_invalid_line = 1
|
||||
self.max_wanted_line = 0
|
||||
end
|
||||
|
||||
function Highlighter:invalidate(idx)
|
||||
self.first_invalid_line = idx
|
||||
self.max_wanted_line = math.min(self.max_wanted_line, #self.doc.lines)
|
||||
|
|
|
@ -59,7 +59,7 @@ function Doc:reset_syntax()
|
|||
local syn = syntax.get(self.filename or "")
|
||||
if self.syntax ~= syn then
|
||||
self.syntax = syn
|
||||
self.highlighter:invalidate(1)
|
||||
self.highlighter:reset()
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue