From 438ed6984ac810dea82a031984daa60be5965f5a Mon Sep 17 00:00:00 2001 From: Guldoman Date: Sat, 25 Jun 2022 00:09:14 +0200 Subject: [PATCH] `drawwhitespace`: Invalidate cache on font size change --- data/plugins/drawwhitespace.lua | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/data/plugins/drawwhitespace.lua b/data/plugins/drawwhitespace.lua index 83a4943a..635a426c 100644 --- a/data/plugins/drawwhitespace.lua +++ b/data/plugins/drawwhitespace.lua @@ -195,13 +195,19 @@ function DocView:draw_line_text(idx, x, y) end local font = (self:get_font() or style.syntax_fonts["whitespace"] or style.syntax_fonts["comment"]) + local font_size = font:get_size() reset_cache_if_needed() if not ws_cache[self.doc.highlighter] or ws_cache[self.doc.highlighter].font ~= font + or ws_cache[self.doc.highlighter].font_size ~= font_size then - ws_cache[self.doc.highlighter] = {font = font} + ws_cache[self.doc.highlighter] = + setmetatable( + { font = font, font_size = font_size }, + { __mode = "k" } + ) end if not ws_cache[self.doc.highlighter][idx] then -- need to cache line