-
Notifications
You must be signed in to change notification settings - Fork 298
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
Support folding for loops and arbitrary blocks #4780
Comments
It also appears immediately invoked function expressions (IIFEs) are also affected by the same bug or a similar bug: void main() {
(() { // This function expression cannot be folded.
print('hi');
})();
} |
This choice was actually deliberate. When folding was first added, VS Code had a hard limit on the number of folding regions and would disable folding if there were more. So originally only some specific things were foldable (classes, methods, etc.). Over time, we've added more as people have requested them, and VS Code moved the 5k limit from all folding provider to only the indent-based provider in microsoft/vscode@20885d5 / microsoft/vscode#36555.
This happens because until the Dart language server is fully initialised, VS Code provides indent-based folding. When the server is available, it switches to the server-provided folding. Now that VS Code was raised the limit (to |
I enabled indent-based folding in my VSCode settings. It's a shame that Dart extension disables folding for loops and other code blocks. |
Fixes Dart-Code/Dart-Code#4780 Fixes Dart-Code/Dart-Code#4723 Change-Id: I6a2f5eb616643df0aaec7fef1b87594f6e223c5f Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/350581 Commit-Queue: Keerti Parthasarathy <keertip@google.com> Reviewed-by: Brian Wilkerson <brianwilkerson@google.com> Reviewed-by: Keerti Parthasarathy <keertip@google.com>
Fixed by dart-lang/sdk@5e1fb3e. The change is in the Dart SDK so will show up in a future SDK release (note a Dart-Code release). |
for
blocks cannot be folded. Un-prefixed top-level blocks cannot be folded either.One workaround is to select the lines containing the block and use the "Create Folding Region from Selection" command.
To Reproduce
Steps to reproduce the behavior:
for
loop on line 6 or the block starting on line 10.Expected behavior
All code blocks should foldable.
Interestingly, upon starting VSCode, these blocks appear foldable initially (the chevron is visible), but then they become unfoldable. You can see this in the last few seconds of this video:
2023-10-07_11-53-19.mp4
Please complete the following information:
You can run the Dart: Collect Diagnostic Information command from the VS Code command palette (
F1
) to easily capture this information or provide it manually.Workspace Environment
Output from 'dart info'
/Users/andrewkolos/Documents/GitHub/flutter/bin/cache/dart-sdk/bin/dart info
If providing this information as part of reporting a bug, please review the information
below to ensure it only contains things you're comfortable posting publicly.
General info
Process info
Output from 'flutter doctor'
/Users/andrewkolos/Documents/GitHub/flutter/bin/flutter doctor -v
The text was updated successfully, but these errors were encountered: