diff --git a/data/core/doc/highlighter.lua b/data/core/doc/highlighter.lua index 5a066ec..6a3237f 100644 --- a/data/core/doc/highlighter.lua +++ b/data/core/doc/highlighter.lua @@ -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) diff --git a/data/core/doc/init.lua b/data/core/doc/init.lua index 0000ead..9d4d2c0 100644 --- a/data/core/doc/init.lua +++ b/data/core/doc/init.lua @@ -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