-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Code folding will collapse entire line containing closing bracket #5521
Comments
Hi @moojek . Thanks for reporting this. Fixing this is tricky, due to limitations of VS Code's folding API. It's line based, and doesn't take character/column positions into account. Our folding algorithm is shared with VS, and can fold at character/column resolution, if that were supported We could omit the last line from the fold, but that would instead do the wrong thing if there is content prior to the closing bracket. Related issues that might lead to a solution from VS Code: |
I mean I am pretty sure it worked a while ago. Did something change since? |
@moojek C++ code folding was added in v0.28.0 of the extension. If you'd prefer to use VS Code's built-in indent-based folding, you can disable C++ code folding with the following in settings.json : |
Thanks! I will use it as workaround now. What am I possibly losing (what are the advantages of C++ folding over VSC)? |
The main advantage of the new code folding is when region blocks are left-indented, such as
in which case the "main" doesn't fold correctly. |
There are also other issues. The following class cannot be collapsed entirely, only per permission section:
The folding algorithm in the C/C++ Extension understands the syntax of the language, so is better able to determine what should be grouped. Though, as per the symptom you encountered, VS Code's folding resolution is per-line, creating some problems when that group should be started/ended within a line. |
I also see this. Especially misleading with |
Same. Similar to the
collapses to
|
In VS Code settings.json add this "editor.foldingStrategy": "indentation" |
Thanks Rob, your solution is really straightforward and useful. |
@sean-mcmanus thanks for your great work : ) code block likes below, the first if folding will hide else if (true) {
if (false) {
;
}
;
} else {
;
} |
thank you for your rapid response |
@vacing The fix is in 1.5.0 (https://github.com/microsoft/vscode-cpptools/releases/tag/1.5.0). |
thank you, it workes fine for the previous case, now I have a new bad case : ( if (true) {
if (true) {
;
} else {
;
}
;
} else if(true) // else or else if(), the most important is no brace here
; |
Type: LanguageService
Describe the bug
Steps to reproduce
Expected behavior
fold is only applied to what's inside the if, not touching the "else" line
Logs
Nothing shows.
Screenshots
Before folding:
Folding with extensions disabled:
Folding with C++ extension:
Additional context
The text was updated successfully, but these errors were encountered: