Skip to content

Commit

Permalink
perf: clean context after all rows done in on_line
Browse files Browse the repository at this point in the history
  • Loading branch information
glepnir committed Aug 28, 2024
1 parent 7a2d7dc commit 0ebb3e2
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions lua/indentmini/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -158,9 +158,16 @@ local function find_current_range(currow_indent)
context.cur_inlevel = math.floor(currow_indent / context.step)
end

local function clean_ctx(row)
if row == context.botrow then
context = { snapshot = {} }
end
end

local function on_line(_, _, bufnr, row)
local sp = find_in_snapshot(row + 1)
if sp.indent == 0 or out_current_range(row) then
clean_ctx(row)
return
end
for i = 1, sp.indent - 1, context.step do
Expand Down Expand Up @@ -189,9 +196,7 @@ local function on_line(_, _, bufnr, row)
buf_set_extmark(bufnr, ns, row, col, opt.config)
opt.config.virt_text_win_col = nil
end
end
if row == context.botrow then
context = { snapshot = {} }
clean_ctx(row)
end
end

Expand Down

0 comments on commit 0ebb3e2

Please sign in to comment.