fix(indent): zero indent for blank lines. Closes #1477

This commit is contained in:
Folke Lemaitre 2025-03-01 23:18:47 +01:00
parent bc2ed15c41
commit cddf714dd6
No known key found for this signature in database
GPG key ID: 41F8B1FBACAE2040

View file

@ -204,6 +204,10 @@ local function get_state(win, buf, top, bottom)
return state
end
function M.debug_win()
Snacks.debug.inspect(states[vim.api.nvim_get_current_win()])
end
--- Called during every redraw cycle, so it should be fast.
--- Everything that can be cached should be cached.
---@param win number
@ -252,7 +256,7 @@ function M.on_win(win, buf, top, bottom)
indents[prev] = indents[prev] or vim.fn.indent(prev)
indents[next] = indents[next] or vim.fn.indent(next)
indent = math.min(indents[prev], indents[next])
if indents[prev] ~= indents[next] then
if indents[prev] ~= indents[next] and indent > 0 then
indent = indent + state.shiftwidth
end
else