Fixing linewrapping bug to do with wordwrapping.

This commit is contained in:
Adam Harrison 2023-04-22 14:54:42 -04:00 committed by George Sokianos
parent aa2ac0a4ce
commit 6714732222
1 changed files with 4 additions and 3 deletions

View File

@ -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