From 261292c6aa727e7d434eeb95dc453e7c8778a4d3 Mon Sep 17 00:00:00 2001 From: jgmdev Date: Fri, 21 Oct 2022 13:53:42 -0400 Subject: [PATCH 1/2] plugin drawwhitespace: allow newline substitution --- data/plugins/drawwhitespace.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/data/plugins/drawwhitespace.lua b/data/plugins/drawwhitespace.lua index a0b8ad60..a074659c 100644 --- a/data/plugins/drawwhitespace.lua +++ b/data/plugins/drawwhitespace.lua @@ -244,7 +244,7 @@ function DocView:draw_line_text(idx, x, y) local color = base_color local draw = false - if e == #text - 1 then + if e >= #text - 1 then draw = show_trailing color = trailing_color elseif s == 1 then From 3da6833249490b2f1b0cbac8030110ba731b6104 Mon Sep 17 00:00:00 2001 From: jgmdev Date: Fri, 21 Oct 2022 13:56:23 -0400 Subject: [PATCH 2/2] docview: do not render newline fixes #1164 --- data/core/docview.lua | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/data/core/docview.lua b/data/core/docview.lua index 693684a1..19b9cebd 100644 --- a/data/core/docview.lua +++ b/data/core/docview.lua @@ -364,9 +364,17 @@ end function DocView:draw_line_text(line, x, y) local default_font = self:get_font() local tx, ty = x, y + self:get_line_text_y_offset() - for _, type, text in self.doc.highlighter:each_token(line) do + local last_token = nil + local tokens = self.doc.highlighter:get_line(line).tokens + local tokens_count = #tokens + if string.sub(tokens[tokens_count], -1) == "\n" then + last_token = tokens_count - 1 + end + for tidx, type, text in self.doc.highlighter:each_token(line) do local color = style.syntax[type] local font = style.syntax_fonts[type] or default_font + -- do not render newline, fixes issue #1164 + if tidx == last_token then text = text:sub(1, -2) end tx = renderer.draw_text(font, text, tx, ty, color) end return self:get_line_height()