Fixed highlighter resetting of syntax on doc filename change

This commit is contained in:
rxi 2020-05-09 16:23:07 +01:00
parent 70f62f3c8a
commit 3d49b6d200
2 changed files with 8 additions and 4 deletions

View File

@ -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)

View File

@ -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