From d0a2c913f505a6e357bb4edff127d00cd3834930 Mon Sep 17 00:00:00 2001 From: Guldoman Date: Sat, 20 Nov 2021 01:18:37 +0100 Subject: [PATCH] Pre-populate the highlighter This avoids problems with calls to `[insert,remove]_notify` on lines that the highlighter has not yet added. --- data/core/doc/init.lua | 3 +++ 1 file changed, 3 insertions(+) diff --git a/data/core/doc/init.lua b/data/core/doc/init.lua index b0f07921..06cde9f9 100644 --- a/data/core/doc/init.lua +++ b/data/core/doc/init.lua @@ -62,12 +62,15 @@ function Doc:load(filename) local fp = assert( io.open(filename, "rb") ) self:reset() self.lines = {} + local i = 1 for line in fp:lines() do if line:byte(-1) == 13 then line = line:sub(1, -2) self.crlf = true end table.insert(self.lines, line .. "\n") + self.highlighter.lines[i] = false + i = i + 1 end if #self.lines == 0 then table.insert(self.lines, "\n")