Skip to content

Commit

Permalink
logic optimize
Browse files Browse the repository at this point in the history
  • Loading branch information
glepnir committed May 3, 2024
1 parent 5f8fb68 commit 9b3a309
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions lua/indentmini/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,18 @@ local function find_row(bufnr, row, curindent, direction, render)
local target_row = row + direction
local count = api.nvim_buf_line_count(bufnr)
while true do
local ok, lines = pcall(api.nvim_buf_get_text, bufnr, target_row, 0, target_row, -1, {})
if not ok or target_row < 0 or target_row > count - 1 then
break
end
local non_empty = #lines[1] ~= 0
local text = api.nvim_buf_get_text(bufnr, target_row, 0, target_row, -1, {})[1]
local non_empty = #text > 0
local target_indent = indent_fn(target_row + 1)
if target_indent == 0 and non_empty and render then
break
elseif non_empty and (render and target_indent > curindent or target_indent < curindent) then
return target_row
end
target_row = target_row + direction
if target_row < 0 or target_row > count - 1 then
return
end
end
end

Expand Down

0 comments on commit 9b3a309

Please sign in to comment.