-
-
Notifications
You must be signed in to change notification settings - Fork 5.3k
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
An unexpected fold is started when "<2" is specified in "foldexpr" #12768
Labels
Comments
can you please create a PR with a test for it? |
emonkak
added a commit
to emonkak/vim
that referenced
this issue
Dec 21, 2023
emonkak
added a commit
to emonkak/vim
that referenced
this issue
Dec 21, 2023
zeertzjq
added a commit
to zeertzjq/neovim
that referenced
this issue
Jan 3, 2024
Problem: a closing fold expression may unexpectedly start a new fold when it should end a fold (reported by Shota Nozaki) Solution: if a fold hasn't started yet, do not immediately start a new fold with level 1 (Shota Nozaki) fixes: vim/vim#12768 closes: vim/vim#13748 vim/vim@0689b87 Co-authored-by: Shota Nozaki <emonkak@gmail.com>
zeertzjq
added a commit
to neovim/neovim
that referenced
this issue
Jan 3, 2024
Problem: a closing fold expression may unexpectedly start a new fold when it should end a fold (reported by Shota Nozaki) Solution: if a fold hasn't started yet, do not immediately start a new fold with level 1 (Shota Nozaki) fixes: vim/vim#12768 closes: vim/vim#13748 vim/vim@0689b87 Co-authored-by: Shota Nozaki <emonkak@gmail.com>
cleong14
pushed a commit
to cleong14/neovim
that referenced
this issue
Jan 16, 2024
…#26876) Problem: a closing fold expression may unexpectedly start a new fold when it should end a fold (reported by Shota Nozaki) Solution: if a fold hasn't started yet, do not immediately start a new fold with level 1 (Shota Nozaki) fixes: vim/vim#12768 closes: vim/vim#13748 vim/vim@0689b87 Co-authored-by: Shota Nozaki <emonkak@gmail.com>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Steps to reproduce
In
'foldexpr'
, "<2" indicates the end of a level 2 fold. However, if no fold has been started yet, it starts a level 1 fold instead.This behavior is unexpected and looks like a bug. But, fixing it may break the existing
'foldexpr'
settings.This issue can be reproduced by sourcing the following script using
:source:
.Expected: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
Actual: [0, 1, 1, 1, 1, 1, 1, 1, 1, 1]
Expected behaviour
Never start a new fold when ending a fold with "<1" or "<2".
I found the code that is causing this issue. Surprisingly, this code has not been modified since 19 years ago. I believe that the following change will fix this issue:
vim/src/fold.c
Line 3365 in 81b8bf5
Version of Vim
9.0.1695
Environment
OS: Gentoo Linux
Terminal: alacritty
$TERM: xterm-256color
shell: zsh
Logs and stack traces
No response
The text was updated successfully, but these errors were encountered: