Skip to content

Code Preview Broken for Multi-Line Compound Declaration #4968

Closed

Description

@Number-3434

The Issue

The Code Preview (shown by moving the cursor over a symbol whilst holding Cmd ⌘) shows the code preview for the first symbol in a multiline compound declartion.

To Reproduce

Copy the following:

late final textAnimationController = AnimationController(
      vsync: this,
      duration: const Duration(milliseconds: 500),
    ),
    healthAnimationController = AnimationController(
      vsync: this,
      duration: const Duration(milliseconds: 200),
      reverseDuration: const Duration(milliseconds: 100),
    ),
    playPauseButtonAnimationController = AnimationController(
      vsync: this,
      duration: const Duration(milliseconds: 400),
    ),
    uiAnimationController = AnimationController(
      vsync: this,
      duration: const Duration(milliseconds: 1000),
    ),
    menuAnimationController = AnimationController(
      vsync: this,
      duration: const Duration(milliseconds: 150),
    ),
    endScreenAnimationController = AnimationController(
      vsync: this,
      duration: const Duration(milliseconds: 400),
    );

Then, type endScreenAnimationController, and move the cursor over a symbol whilst holding Cmd ⌘ to show the symbol preview. The symbol preview will show the first line of compound declaration, instead of the line where endScreenAnimationController is declared.

Activity

  1. DanTup commented on Jan 31, 2024

    @DanTup
    Member

    Thanks, I can repro this:

    image

    Seems like in the Definition response we return the whole declaration list range and not only the single variable declaration:

    {
        "id": 204,
        "jsonrpc": "2.0",
        "result": [
            {
                "originSelectionRange": {
                    "end": { "character": 9, "line": 14 },
                    "start": { "character": 8, "line": 14 }
                },
                "targetRange": {
                    "end": { "character": 3, "line": 11 },
                    "start": { "character": 0, "line": 8 } // should be 10
                },
                "targetSelectionRange": {
                    "end": { "character": 5, "line": 10 },
                    "start": { "character": 4, "line": 10 }
                },
                "targetUri": "file:///C:/Dev/Test%20Projects/Archive-2024-01/dart_sample/test/good_test.dart"
            }
        ]
    }
  2. added this to the v3.84.0 milestone on Jan 31, 2024
  3. added
    in editorRelates to code editing or language features
    in lsp/analysis serverSomething to be fixed in the Dart analysis server
    on Jan 31, 2024
  4. Number-3434 commented on Jan 31, 2024

    @Number-3434
    Author

    Okay, thanks!

    Also, would it be possible to show the first part of the declaration in the preview?

    For example, in your example above, could you show var b?

  5. DanTup commented on Jan 31, 2024

    @DanTup
    Member

    Unfortunately not.. VS Code just asks us for the range of the definition and then it goes and reads the file contents for that range and shows it here.

    If the declaration is a single variable, we could still expand it to be the whole declaration, but otherwise it will only be the range from the start of the variable name to the end of the value - we can't provide multiple ranges.

  6. modified the milestones: v3.84.0, v3.86.0 on Feb 20, 2024
  7. modified the milestones: v3.86.0, v3.88.0 on Apr 2, 2024
  8. DanTup commented on Apr 17, 2024

    @DanTup
    Member

    This is fixed by dart-lang/sdk@0b170c7. The change is in the Dart analysis server so will show up in a future Dart/Flutter SDK release (rather than a Dart-Code extension release).

  9. added
    relies on sdk changesSomething that requires changes in the Dart/Flutter SDK to ship before it will become available
    on May 1, 2024
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