From 8a9bac7de39c34a52a5cbfa80c35ab9c79ad599a Mon Sep 17 00:00:00 2001 From: Guldoman Date: Sun, 30 Oct 2022 02:54:30 +0100 Subject: [PATCH] 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. --- data/plugins/drawwhitespace.lua | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/data/plugins/drawwhitespace.lua b/data/plugins/drawwhitespace.lua index a074659..89be875 100644 --- a/data/plugins/drawwhitespace.lua +++ b/data/plugins/drawwhitespace.lua @@ -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)