Skip to content

Commit

Permalink
Fixed highlighter resetting of syntax on doc filename change
Browse files Browse the repository at this point in the history
  • Loading branch information
rxi committed May 9, 2020
1 parent 70f62f3 commit 3d49b6d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
10 changes: 7 additions & 3 deletions data/core/doc/highlighter.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion data/core/doc/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 3d49b6d

Please sign in to comment.