-
Notifications
You must be signed in to change notification settings - Fork 316
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 not working properly in certain circumstances #4121
Comments
So the issue is for the functions with multiline parameters. I opened an issue for the VS Code and I think they have provided valuable debug info. |
Thanks for the link. I didn't realise this used to work - it looks like there were some changes in VS Code (microsoft/vscode#155302) that stopp it from handling ranges that start/end on the same line. The data from the server initially contains column numbers (so they don't really intersect at all), but VS Code only supports line folding. I think we'll need to detect this and reduce the first range to end on the line before the next one begins in this case. |
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). |
+ convert LSP folding tests to use TestCode parser. A change in VS Code means two folding regions are no longer allowed to end/start on the same line (the second range is silently dropped). This truncates folding regions if they end on the same line that another starts to end on the line before (but only if a client only supports line-folding mode). Fixes Dart-Code/Dart-Code#4121. Change-Id: Ic26f58f84c44a01ae5157c336ed0f207d1c0eeb8 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/261900 Reviewed-by: Brian Wilkerson <brianwilkerson@google.com> Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Fixed by dart-lang/sdk@604bf2f. |
@methompson looking at the change dart-lang/sdk@604bf2f, it looks like the first Dart SDK it was included in is 2.19.0-257.0.dev: The beta you're on is 2.19.0-255.2.beta so seems like it was cut just before this. Presumably the fix will be in the next beta (I actually thought there had been a more recent beta, but apparently not). Hope this helps! |
@methompson thanks for the example! There's definitely something wrong there. I've filed #4242 with a cut-down example and will follow up there. |
Describe 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:
_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
2022-08-25_10-39-03.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:
I have reproduced this on Windows and another MacBook. Let me know if more information on those environments is needed.
(edit: typo)
The text was updated successfully, but these errors were encountered: