Skip to content

Code folding for switch statements #4506

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

Closed
stereotype441 opened this issue Apr 24, 2023 · 11 comments
Closed

Code folding for switch statements #4506

stereotype441 opened this issue Apr 24, 2023 · 11 comments
Labels
in editor Relates to code editing or language features in lsp/analysis server Something to be fixed in the Dart analysis server is enhancement relies on sdk changes Something that requires changes in the Dart/Flutter SDK to ship before it will become available
Milestone

Comments

@stereotype441
Copy link

With the addition of patterns to the Dart language, it would be nice if code folding could be used on switch statements, much as it can be used for other control flow such as if statements.

For example, given the code:

switch (expr) {
  case 0:
    statement;
    statement;
    statement;
  case 1:
    statement;
    statement;
    statement;
}

It would be nice to be able to collapse individual cases, e.g.

switch (expr) {
  case 0:case 1:
    statement;
    statement;
    statement;
}

Or to collapse the entire switch statement:

switch (expr) {…
}
@DanTup DanTup added this to the v3.66.0 milestone Apr 25, 2023
@DanTup DanTup added in editor Relates to code editing or language features in lsp/analysis server Something to be fixed in the Dart analysis server relies on sdk changes Something that requires changes in the Dart/Flutter SDK to ship before it will become available labels Apr 25, 2023
copybara-service bot pushed a commit to dart-lang/sdk that referenced this issue Apr 25, 2023
Fixes Dart-Code/Dart-Code#4506.

Change-Id: Idd5924d04e9ffffc49f088ca6884393ea72e9bea
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/298120
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
@DanTup
Copy link
Member

DanTup commented Apr 25, 2023

This landed in dart-lang/sdk@528c75a. It's entirely a language server change so will show up with a new SDK release and doesn't require an extension update.

@DanTup DanTup closed this as completed Apr 25, 2023
@Fernandomr88
Copy link

Fernandomr88 commented Jun 2, 2023

not working for me at VScode, using latest version of the SDK @DanTup

Captura de Tela 2023-06-02 às 10 26 28

@DanTup
Copy link
Member

DanTup commented Jun 2, 2023

@Fernandomr88 the change was made after the branch for the last SDK (Dart 3.0), so it will show up in a future SDK release (3.1, etc.). It should be available on beta/dev/master channels already.

@Fernandomr88
Copy link

@Fernandomr88 the change was made after the branch for the last SDK (Dart 3.0), so it will show up in a future SDK release (3.1, etc.). It should be available on beta/dev/master channels already.

sorry for my mistake @DanTup, hadn't noticed that "tiny" detail lol, looking forward for that release

@DanTup
Copy link
Member

DanTup commented Jun 2, 2023

np! FWIW I did just test it in latest code to verify, and it does seem to work as you'd expect :)

Screenshot 2023-06-02 at 15 10 20

@Fernandomr88
Copy link

@DanTup hey Dan, any hint on when this will be released?

@DanTup
Copy link
Member

DanTup commented Sep 4, 2023

@Fernandomr88 this change shipped in Dart 3.1 / Flutter 3.13. It seems to work in my testing:

folding.mp4

If you have code where it doesn't work, could you file a new issue with an explicit (complete) code sample so I can test with it? Please also include your exact SDK version.

Thanks!

@Fernandomr88
Copy link

@Fernandomr88 this change shipped in Dart 3.1 / Flutter 3.13. It seems to work in my testing:

folding.mp4
If you have code where it doesn't work, could you file a new issue with an explicit (complete) code sample so I can test with it? Please also include your exact SDK version.

Thanks!

Hey @DanTup , it worked indeed. Sorry for the mess, I was commuting and remembered this and asked 🫠

@DanTup
Copy link
Member

DanTup commented Sep 5, 2023

Great, thanks for confirming :-)

@Fernandomr88
Copy link

@DanTup should I open an issue for this case too? or is it meant to be like this?
There's no folding on these cases:

image

@DanTup
Copy link
Member

DanTup commented Sep 5, 2023

@Fernandomr88 generally we've only added folding regions for things that have been requested (in part because VS Code used to have a fairly low limit on how many folding regions it would support, so having too many resulted in warnings being shown). If there are things you'd like to fold that aren't currently foldable, please do file additional issues :-) Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in editor Relates to code editing or language features in lsp/analysis server Something to be fixed in the Dart analysis server is enhancement relies on sdk changes Something that requires changes in the Dart/Flutter SDK to ship before it will become available
Projects
None yet
Development

No branches or pull requests

3 participants