Merge pull request #681 from Guldoman/prepopulate_highlighter
Prepopulate highlighter
This commit is contained in:
commit
43a6e21135
|
@ -41,6 +41,13 @@ end
|
||||||
|
|
||||||
function Highlighter:reset()
|
function Highlighter:reset()
|
||||||
self.lines = {}
|
self.lines = {}
|
||||||
|
self:soft_reset()
|
||||||
|
end
|
||||||
|
|
||||||
|
function Highlighter:soft_reset()
|
||||||
|
for i=1,#self.lines do
|
||||||
|
self.lines[i] = false
|
||||||
|
end
|
||||||
self.first_invalid_line = 1
|
self.first_invalid_line = 1
|
||||||
self.max_wanted_line = 0
|
self.max_wanted_line = 0
|
||||||
end
|
end
|
||||||
|
|
|
@ -47,7 +47,7 @@ function Doc:reset_syntax()
|
||||||
local syn = syntax.get(self.filename or "", header)
|
local syn = syntax.get(self.filename or "", header)
|
||||||
if self.syntax ~= syn then
|
if self.syntax ~= syn then
|
||||||
self.syntax = syn
|
self.syntax = syn
|
||||||
self.highlighter:reset()
|
self.highlighter:soft_reset()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -62,12 +62,15 @@ function Doc:load(filename)
|
||||||
local fp = assert( io.open(filename, "rb") )
|
local fp = assert( io.open(filename, "rb") )
|
||||||
self:reset()
|
self:reset()
|
||||||
self.lines = {}
|
self.lines = {}
|
||||||
|
local i = 1
|
||||||
for line in fp:lines() do
|
for line in fp:lines() do
|
||||||
if line:byte(-1) == 13 then
|
if line:byte(-1) == 13 then
|
||||||
line = line:sub(1, -2)
|
line = line:sub(1, -2)
|
||||||
self.crlf = true
|
self.crlf = true
|
||||||
end
|
end
|
||||||
table.insert(self.lines, line .. "\n")
|
table.insert(self.lines, line .. "\n")
|
||||||
|
self.highlighter.lines[i] = false
|
||||||
|
i = i + 1
|
||||||
end
|
end
|
||||||
if #self.lines == 0 then
|
if #self.lines == 0 then
|
||||||
table.insert(self.lines, "\n")
|
table.insert(self.lines, "\n")
|
||||||
|
|
Loading…
Reference in New Issue