fix(treesitter): don't open fold when o/O adds a line below #28709

Problem:
`o`-ing on a folded line opens the fold, because the new line gets the
fold level from the above line (level '='), which extends the fold to
the new line. `O` has a similar problem when run on the line below a
fold.

Solution:
Use -1 for the added line to get the lower level from the above/below
line.
This commit is contained in:
Jaehwang Jung
2024-06-20 22:37:09 +09:00
parent 4b25fe09cc
commit ca10442e01
2 changed files with 63 additions and 2 deletions

View File

@@ -87,7 +87,7 @@ end
---@param srow integer
---@param erow integer 0-indexed, exclusive
function FoldInfo:add_range(srow, erow)
list_insert(self.levels, srow + 1, erow, '=')
list_insert(self.levels, srow + 1, erow, -1)
list_insert(self.levels0, srow + 1, erow, -1)
end