diff options
author | jgmdev <jgmdev@gmail.com> | 2022-05-22 14:37:28 -0400 |
---|---|---|
committer | jgmdev <jgmdev@gmail.com> | 2022-05-22 14:37:28 -0400 |
commit | 76bacb1fe9d0d92bb8c22a6767a98b0589d4bdd3 (patch) | |
tree | 11091b18f989d310fe43996b60e15ff482520c50 /plugins/selectionhighlight.lua | |
parent | 694132ec9d81ced3d8c6ebbf10e451bbc5a9e65b (diff) | |
download | lite-xl-plugins-76bacb1fe9d0d92bb8c22a6767a98b0589d4bdd3.tar.gz lite-xl-plugins-76bacb1fe9d0d92bb8c22a6767a98b0589d4bdd3.zip |
Fix various plugins for linewrapping
Diffstat (limited to 'plugins/selectionhighlight.lua')
-rw-r--r-- | plugins/selectionhighlight.lua | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/plugins/selectionhighlight.lua b/plugins/selectionhighlight.lua index 2835eec..d17acff 100644 --- a/plugins/selectionhighlight.lua +++ b/plugins/selectionhighlight.lua @@ -16,15 +16,15 @@ end local draw_line_body = DocView.draw_line_body -function DocView:draw_line_body(idx, x, y) - draw_line_body(self, idx, x, y) +function DocView:draw_line_body(line, x, y) + local line_height = draw_line_body(self, line, x, y) local line1, col1, line2, col2 = self.doc:get_selection(true) if line1 == line2 and col1 ~= col2 then local selection = self.doc:get_text(line1, col1, line2, col2) if not selection:match("^%s+$") then local lh = self:get_line_height() local selected_text = self.doc.lines[line1]:sub(col1, col2 - 1) - local current_line_text = self.doc.lines[idx] + local current_line_text = self.doc.lines[line] local last_col = 1 while true do local start_col, end_col = current_line_text:find( @@ -32,9 +32,9 @@ function DocView:draw_line_body(idx, x, y) ) if start_col == nil then break end -- don't draw box around the selection - if idx ~= line1 or start_col ~= col1 then - local x1 = x + self:get_col_x_offset(idx, start_col) - local x2 = x + self:get_col_x_offset(idx, end_col + 1) + if line ~= line1 or start_col ~= col1 then + local x1 = x + self:get_col_x_offset(line, start_col) + local x2 = x + self:get_col_x_offset(line, end_col + 1) local color = style.selectionhighlight or style.syntax.comment draw_box(x1, y, x2 - x1, lh, color) end @@ -42,5 +42,6 @@ function DocView:draw_line_body(idx, x, y) end end end + return line_height end |