Code folding not working properly in certain circumstances
See original GitHub issueDescribe the bug
At least in top-level functions, code folding can sometimes be unavailable. For example, I might be able to fold a function signature, but not the implementation block (and some but not all blocks within). While this is difficult to describe, it is most easily observed through reproduction or the videos below.
The issue does not appear to happen in Android Studio, so I’m guessing this is not an SDK issue (though VSCode can fold parameter lists, while Android Studio cannot–I’m not sure if this is intended).
To Reproduce Steps to reproduce the behavior:
- Clone https://github.com/flutter/flutter (head is f477c8b184d2364fcef0a15cee6ab5c909188229 at the time of writing)
- Open run_hot.dart (packages/flutter_tools/lib/src)
- Fold all code. This can be done by opening the command palette (Cmd/Ctrl+Shift+P) and typing Fold All.
- You should see multiple unfolded blocks of code. As a specific example, the body
_defaultReassembleHelper
won’t be folded, andfor
loops within might not be folded as well. See screenshots below.
Expected behavior All code blocks should be folded after issuing a Fold All command. Interestingly, copying the contents of the file into a new editor and then using Fold All appears to work as expected. However, saving the file (say, to my Desktop) will unfold the code, and if I try to Fold All again, it is still slightly broken.
Screenshots The issue happening in run_hot.dart
https://user-images.githubusercontent.com/9027551/186756324-d407768f-3190-4b80-92cb-30b4d8e1ce55.mp4
The issue not happening if I copy and paste a problematic function into a new editor: https://user-images.githubusercontent.com/9027551/186756680-939ba825-7c52-44da-9324-b183e5add931.mp4
The issue happening if I save the new file to disk: https://user-images.githubusercontent.com/9027551/186756837-88813e9f-1048-409e-9d83-c8e4e06bf0c5.mp4
Please complete the following information:
- Operating System and version: macOS Monterey 12.5.1
- VS Code version: 1.70.2
- Dart extension version: 3.46.1
- Dart/Flutter SDK version: 2.17.6
- Target device (if the issue relates to Flutter debugging): N/A
I have reproduced this on Windows and another MacBook. Let me know if more information on those environments is needed.
(edit: typo)
Issue Analytics
- State:
- Created a year ago
- Reactions:2
- Comments:8 (5 by maintainers)
Top GitHub Comments
Working on a fix at https://dart-review.googlesource.com/c/sdk/+/261900/. I’ll close this once it lands. It’s a change in the Dart analysis server, so will ship in a future SDK release (rather than a Dart VS Code extension release).
Fixed by https://github.com/dart-lang/sdk/commit/604bf2fe3bdfd56868df80b7c9263e9272344e30.