Avoid recreating `line_numbers` table when a recalc is needed

This commit is contained in:
Guldoman 2021-08-30 17:40:08 +02:00 committed by Francesco
parent 4d0656ad7e
commit 235b1f0385
1 changed files with 2 additions and 1 deletions

View File

@ -575,6 +575,7 @@ function Doc:indent_text(unindent, line1, col1, line2, col2)
return line1, col1 + #text, line1, col1 + #text
end
function Doc:update_max_line_len_range(start_line, end_line)
local line_numbers = self.long_lines.line_numbers
local max_length = self.long_lines.length
@ -595,7 +596,7 @@ function Doc:update_max_line_len_range(start_line, end_line)
if not next(line_numbers) then
-- Recalc needed
self.long_lines.length = 0
self.long_lines.line_numbers = { }
self.long_lines.line_numbers = line_numbers
return self:update_max_line_len_range(1, #self.lines)
end