Code change:
Issue Type: <bBug</ba JS file: Fold and place cursor after the opening of the class Bug Nothing happens VS Code version: Code - Insiders 1.61.0-insider (Universal) (, 2021-09-14T05:14:54.400Z) OS version: Darwin x64 20.6.0 Restricted Mode: No <details<summarySystem Info</summary </details<details<summaryExtensions (55)</summaryExtensionVersion ------ salesforce-soql-editor1.8.0 comment-tagged-templates0.3.1 docs-view0.0.9 emojisense0.9.0 folder-source-actions0.2.1 jsdoc-markdown-highlighting0.0.1 markdown-checkbox0.3.2 markdown-emoji0.2.1 markdown-yaml-preamble0.1.0 test-ext0.0.1 vscode-eslint2.1.25 typescript-notebook2.0.3 gitlens11.6.0 tsl-problem-matcher0.4.0 EditorConfig0.16.4 codespaces1.0.5 vscode-pull-request-github-insiders2021.9. vscode-drawio1.6.2 vscode-postfix-ts1.9.4 latex-workshop8.20.2 vscode-platform-specific-sample1.15.0 vscode-platform-specific-sample1.5.0 vscode-memfs0.0.3 template-string-converter0.5.3 vscode-azurefunctions1.5.1 vscode-azureresourcegroups0.4.0 vscode-docker1.16.1 vscode-language-pack-de1.60.3 vscode-edge-devtools1.3.0 python2021.10.-dev vscode-pylance2021.9.2-pre.1 jupyter2021.9. jupyter-keymap1.0.0 remote-containers0.194.0 remote-ssh0.65.7 remote-ssh-edit0.65.7 azure-account0.9.8 hexeditor1.8.2 js-debug-nightly2021.9.417 live-server0.2.8 vscode-github-issue-notebooks0.0.106 vscode-typescript-next4.5. vsliveshare1.0.4836 debugger-for-chrome4.13.0 vetur0.34.1 java0.81.0 code-spell-checker2.0.4 rest-book4.2.0 ayu1.0.5 luna-paint0.9.0 sort-lines1.9.0 vscodeintellicode1.2.14 vscode-java-debug0.35.0 vscode-java-dependency0.18.7 vscode-java-test0.31.3 (2 theme extensions excluded) </details<details<summaryA/B Experiments</summary</details<!-- generated by issue reporter --
I'm trying to document this command but find its behavior difficult to understand and rather unpredictable This could be wrong, but I think it tries looking for the next fold above the current level. In the case above, that means that works if you are inside another method: But it doesn't work if you are in the class body I'd expect this command to work more like where it just jumps to the next folded location in the file
FYI Got to next fold looks for the next fold of the same level. In the example above there's no such fold
Thanks for tagging me, The way I have fold jumping working is that it takes the cursor position and figures out what fold you are currently in. From there, it checks if you want the next previous or parent fold. Parent is pretty easy. It just gets the fold that's at level X - 1. For next and previous fold, they are implemented as the next or previous fold at the same level. The reason for that is because it makes it easy to find associated parts of the file. For example, if you are at an , , or fold, you can easily navigate to the other conditions. Similarly, in the above example, if you are on function , you can easily jump to the other functions that are defined. I don't think it's valuable to jump to the next or previous fold by file order. For example, in the below code it would not make sense to me to have jump to next fold go to b1, then c1, then c2, then a2. Please let me know if you want me to make any changes though.
We need a better label then: ?
That seems reasonable. Want me to do that? I probably shouldn't change the actually command ID though, right? That would break key bindings.
Thanks for the explanation. I agree that this should be renamed. Even with a better name though, I still find the behavior from my example confusing. When the cursor is inside the class body, I'd expect that the folding points for and would be siblings to the cursor's location (because they all have the same folding parent). Instead though we jump out of the class entirely
One other note on the name: maybe the command should call these something like instead of ? Conceptually I think of a as being code you've actually folded, but my understanding is that these commands actually jump between foldable lines in the file
sounds good to me. I see how that's confusing, so I put together this JS sample to illustrate where the "next fold" is for different cursor positions: Cursor 2's next is straightforward since you're on a folding point. Cursor 3's next I think is reasonable. You are in a fold, so you find the folding point and go to the next of that. Cursor 1 and 5's next start getting a little weird, but following the same logic as cursor 3, it seems logical that is the folding point, so the next sibling is at . Cursor 4 is basically your original question. I agree that it gets a little confusing. The logic is the same as 1, 3, and 5, but visually, if you're between 2 folding points, I could understand the desire for it to go to those points. I think the confusion stems from using the command when you're not on a folding point line. If you are, I think it's easy to understand, but when you aren't, not so much. What do you think of the following? If you are on a folding point line, do what it does now. not, go to the next folding point sequentially. With those updates, the above example looks like this:
We don't use 'folding points' as a term. I suggest 'folding range'
Ok. What do you think of changing the implementation as I mentioned in my previous comment?
Yes I like the suggestion (I thumbed up it :-) )
I wish I could turn on reaction notifications in GitHub. I implemented this in . I update the command from "Fold" to "Folding Region", but I did not add "Sibling". I hit a bit of a dilemma there. With the change, it's no longer necessarily a sibling. However, I can still see people getting confused by previous or next folding region command "not working" when you are on the first or last sibling folding region's start line. For example, in the above example, the previous command won't move you when you are at . I think that's really valuable. It lets you move up and down the different cases of branches without going past them. I wouldn't want to run previous at and end up at , then next brings me to . Any suggestions for that? I'm pretty sure nobody would want the command label to be "Go to Previous Folding Range, but Stop at First Sibling", but that's essentially what this does.
/verified Looks to follow the logic set out by I used this example: When on line 8 it jumps nowhere is a little confusing, but that's because the next folding range is the current?
That's because it's the last sibling. The benefit is that you can move to previous and next sibling folding ranges without stepping out of them (at which point going to the next or previous sibling won't be the original set of siblings you were on). I agree, it's confusing, but I think it's valuable to do it this way.

Related discussion:
text: */ export function getPreviousFoldLine(lineNumber: number, foldingModel: FoldingModel): number | null { let foldingRegion = foldingModel.getRegionAtLine(lineNumber); <del> if (foldingRegion !== null) { </del> <ins> // If on the folding range start line, go to previous sibling. if (foldingRegion !== null && foldingRegion.startLineNumber === lineNumber) { </ins> // If current line is not the start of the current fold, go to top line of current fold. If not, go to previous fold. if (lineNumber !== foldingRegion.startLineNumber) { return foldingRegion.startLineNumber;