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

foldexpr '<1' results in a level-3 fold #15104

Open
lilydjwg opened this issue Jun 25, 2024 · 2 comments
Open

foldexpr '<1' results in a level-3 fold #15104

lilydjwg opened this issue Jun 25, 2024 · 2 comments
Labels

Comments

@lilydjwg
Copy link
Contributor

Steps to reproduce

  1. Edit the following file with vim --clean:
/
├── e
│   └── d
│       └── c
│           ├── _a
│           └── _b
└── f

x directories, y files
  1. source the following vimscript:
let s:fold_results = [ '>1', '>2', '>3', '>4', '4', '<4', '<1', '0', '0' ]

function FoldExpr(lnum)
  return s:fold_results[a:lnum-1]
endfunction

set foldmethod=expr foldexpr=FoldExpr(v:lnum)
  1. observe that line 7 is at level 3

Expected behaviour

<1 should end any higher-level folds and end at level 1.

Version of Vim

9.1.514

Environment

Arch Linux, GNOME Termianl / GTK GUI

Logs and stack traces

No response

@lilydjwg lilydjwg added the bug label Jun 25, 2024
@zzzyxwvut
Copy link
Contributor

The following lists appear to correctly map fold levels for
the example file:

let s:fold_results = [ '>1', '>2', '>3', '>4', '4', '<2', '<1', '0', '0' ]
let s:fold_results = [ '>1', '>2', '>3', '>4', '4', 's3', '<1', '0', '0' ]
let s:fold_results = [ '1', '2', '3', '4', '=', '=', '1', '0', '0' ]

I guess, the outermost (shallowest) level is expected for
< when multiple folds end on the same line.

@lilydjwg
Copy link
Contributor Author

Yes, after adjusting the < value it folds as expected. But the doc doesn't say so. So either this should be fixed, or the doc should be updated, shouldn't it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants