Skip to content

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

Closed

Description

@kpsroka

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

Activity

  1. added this to the v3.62.0 milestone on Mar 16, 2023
  2. added
    in editorRelates to code editing or language features
    in lsp/analysis serverSomething to be fixed in the Dart analysis server
    relies on sdk changesSomething that requires changes in the Dart/Flutter SDK to ship before it will become available
    on Mar 16, 2023
  3. DanTup commented on Mar 16, 2023

    @DanTup
    Member

    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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    in editorRelates to code editing or language featuresin lsp/analysis serverSomething to be fixed in the Dart analysis serveris bugrelies on sdk changesSomething that requires changes in the Dart/Flutter SDK to ship before it will become available

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions