fix(indent): when at edge of two blocks, prefer the one below. See #231

This commit is contained in:
Folke Lemaitre 2024-12-12 06:42:33 +01:00
parent 6ee9e4e71d
commit 2457d913dc
No known key found for this signature in database
GPG key ID: 41F8B1FBACAE2040

View file

@ -232,11 +232,17 @@ function IndentScope:find(opts)
-- adjust line to the nearest indent block
if prev_i <= indent and next_i > indent then
-- at top edge
line = next_l
indent = next_i
elseif next_i <= indent and prev_i > indent then
-- at bottom edge
line = prev_l
indent = prev_i
elseif next_i > indent and prev_i > indent then
-- at edge of two blocks. Prefer the one below.
line = next_l
indent = next_i
end
-- expand to include bigger indents