From 116c14679d7ee4fc31390eb8d912f2fcdfb25ec5 Mon Sep 17 00:00:00 2001 From: Adam Harrison Date: Sat, 22 Apr 2023 14:54:42 -0400 Subject: [PATCH] Fixing linewrapping bug to do with wordwrapping. --- data/plugins/linewrapping.lua | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/data/plugins/linewrapping.lua b/data/plugins/linewrapping.lua index b287c523..e461ae52 100644 --- a/data/plugins/linewrapping.lua +++ b/data/plugins/linewrapping.lua @@ -485,7 +485,7 @@ local old_draw_line_body = DocView.draw_line_body function DocView:draw_line_body(line, x, y) if not self.wrapped_settings then return old_draw_line_body(self, line, x, y) end local lh = self:get_line_height() - local idx0 = get_line_idx_col_count(self, line) + local idx0, _, count = get_line_idx_col_count(self, line) for lidx, line1, col1, line2, col2 in self.doc:get_selections(true) do if line >= line1 and line <= line2 then if line1 ~= line then col1 = 1 end @@ -493,12 +493,14 @@ function DocView:draw_line_body(line, x, y) if col1 ~= col2 then local idx1, ncol1 = get_line_idx_col_count(self, line, col1) local idx2, ncol2 = get_line_idx_col_count(self, line, col2) + local start = 0 for i = idx1, idx2 do local x1, x2 = x + (idx1 == i and self:get_col_x_offset(line1, col1) or 0) if idx2 == i then x2 = x + self:get_col_x_offset(line, col2) else - x2 = x + self:get_col_x_offset(line, get_idx_line_length(self, i, line) + 1, true) + start = start + get_idx_line_length(self, i, line) + x2 = x + self:get_col_x_offset(line, start + 1, true) end renderer.draw_rect(x1, y + (i - idx0) * lh, x2 - x1, lh, style.selection) end @@ -514,7 +516,6 @@ function DocView:draw_line_body(line, x, y) end end if draw_highlight then - local _, _, count = get_line_idx_col_count(self, line) for i=1,count do self:draw_line_highlight(x + self.scroll.x, y + lh * (i - 1)) end