Skip to content
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

"Use curly braces" quick fix removes comment before the expression guearded by if statement #4440

Closed
kpsroka opened this issue Mar 15, 2023 · 1 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 bug relies on sdk changes Something that requires changes in the Dart/Flutter SDK to ship before it will become available
Milestone

Comments

@kpsroka
Copy link

kpsroka commented Mar 15, 2023

Describe the bug
If a comment precedes expression guarded by if statement without curly braces, the "Use curly braces" quick fix removes the comment.

To Reproduce

  1. Make sure curly_braces_in_flow_control_structures lint rule is enforced
  2. Insert the following code:
if (identical(true, false))
  // This is a nice comment.
  throw Exception();
  1. Open quick fixes suggestions in VSCode at the if statement line.
  2. Apply "Use curly braces" fix.

The resulting code is

if (identical(true, false)) {
  throw Exception();
}

Expected behavior
The resulting code should be:

if (identical(true, false)) {
  // This is a nice comment.
  throw Exception();
}

Please complete the following information:

  • Operating System and version: MacOS 13.1 (Ventura)
  • VS Code version: 1.76.1 (Universal)
  • Dart extension version: v3.60.1
  • Dart/Flutter SDK version: 2.19.2 / 3.7.3
@kpsroka kpsroka added the is bug label Mar 15, 2023
@DanTup DanTup added this to the v3.62.0 milestone Mar 16, 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 Mar 16, 2023
copybara-service bot pushed a commit to dart-lang/sdk that referenced this issue Mar 16, 2023
…aces

Fixes Dart-Code/Dart-Code#4440.

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

DanTup commented Mar 16, 2023

Thanks for the report! This is fixed by dart-lang/sdk@454219b.

The change is in the Dart analysis server so will ship with a future Dart/Flutter SDK release rather than show up in the VS Code extension release.

@DanTup DanTup closed this as completed Mar 16, 2023
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 bug 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

2 participants