Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

tomtomjhj
Copy link
Sponsor Contributor

@tomtomjhj tomtomjhj commented May 11, 2024

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.


Originally, -1 was used for the added line, but I changed it to '=' in #26506 because it looked nicer on the markdown test case (the "doesn't open folds that are not touched" test), but it turns out this is quite bad. This PR reverts that change.

@tomtomjhj tomtomjhj changed the title fix(treesitter): don't let o open fold under cursor fix(treesitter): don't extend closed fold with o/O May 11, 2024
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.
@tomtomjhj tomtomjhj changed the title fix(treesitter): don't extend closed fold with o/O fix(treesitter): don't open fold when adding a line below it with o/O May 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant