From 0ebb3e20953d109a4867080a158749062fce888c Mon Sep 17 00:00:00 2001 From: glepnir Date: Wed, 28 Aug 2024 19:21:11 +0800 Subject: [PATCH] perf: clean context after all rows done in on_line --- lua/indentmini/init.lua | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/lua/indentmini/init.lua b/lua/indentmini/init.lua index e347025..685043c 100644 --- a/lua/indentmini/init.lua +++ b/lua/indentmini/init.lua @@ -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 @@ -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