Fix `drawwhitespace` drawing lines with different substitution kinds

When multiple substitution kinds are present in the same line, they're 
placed in the cache in an order that's spatially consistent only between 
items of the same kind.
Because we stopped drawing after we reached the first invisible 
substitution, the subsequent kinds weren't drawn even if they should 
have been.
This commit is contained in:
Guldoman 2022-10-30 02:54:30 +01:00
parent 0030c69524
commit 8a9bac7de3
No known key found for this signature in database
GPG Key ID: EA928C8BDA1A8825
1 changed files with 6 additions and 5 deletions

View File

@ -290,14 +290,15 @@ function DocView:draw_line_text(idx, x, y)
local ty = y + self:get_line_text_y_offset()
local cache = ws_cache[self.doc.highlighter][idx]
for i=1,#cache,4 do
local sub = cache[i]
local tx = cache[i + 1] + x
local tw = cache[i + 2]
local color = cache[i + 3]
if tx + tw >= x1 then
tx = renderer.draw_text(font, sub, tx, ty, color)
if tx <= x2 then
local sub = cache[i]
local color = cache[i + 3]
if tx + tw >= x1 then
tx = renderer.draw_text(font, sub, tx, ty, color)
end
end
if tx > x2 then break end
end
return draw_line_text(self, idx, x, y)