Skip to content

Commit

Permalink
perf: remove goto
Browse files Browse the repository at this point in the history
  • Loading branch information
glepnir committed Aug 26, 2024
1 parent 1359b5b commit be9996a
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions lua/indentmini/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -164,28 +164,29 @@ local function on_line(_, _, bufnr, row)
for i = 1, sp.indent - 1, context.step do
local col = i - 1
local level = math.floor(col / context.step) + 1
if level < opt.minlevel or (opt.only_current and level ~= context.cur_inlevel) then
goto continue
end
local row_in_curblock = context.range_srow
and (row > context.range_srow and row < context.range_erow)
local higroup = row_in_curblock and level == context.cur_inlevel and 'IndentLineCurrent'
or 'IndentLine'
if opt.only_current and row_in_curblock and level ~= context.cur_inlevel then
higroup = 'IndentLineCurHide'
end
if not vim.o.expandtab or sp.is_tab then
col = level - 1
end
if col >= context.leftcol and col < sp.indent_cols then
if
col >= context.leftcol
and level >= opt.minlevel
and (not opt.only_current or level == context.cur_inlevel)
and col < sp.indent_cols
then
local row_in_curblock = context.range_srow
and (row > context.range_srow and row < context.range_erow)
local higroup = row_in_curblock and level == context.cur_inlevel and 'IndentLineCurrent'
or 'IndentLine'
if opt.only_current and row_in_curblock and level ~= context.cur_inlevel then
higroup = 'IndentLineCurHide'
end
opt.config.virt_text[1][2] = higroup
if sp.is_empty and col > 0 then
opt.config.virt_text_win_col = i - 1 - context.leftcol
end
buf_set_extmark(bufnr, ns, row, col, opt.config)
opt.config.virt_text_win_col = nil
end
::continue::
end
if row == context.botrow then
context = { snapshot = {} }
Expand Down

0 comments on commit be9996a

Please sign in to comment.