dart-lang / sdk

The Dart SDK, including the VM, JS and Wasm compilers, analysis, core libraries, and more.
https://dart.dev
BSD 3-Clause "New" or "Revised" License
10.3k stars 1.59k forks source link

CTRL + Click on alias defined multiple times results in weird output #56931

Open FMorschel opened 1 month ago

FMorschel commented 1 month ago

Repro:

  1. Empty file a.dart
  2. File b.dart with class Foo {} inside.
  3. Create a file main.dart with the following content:
import 'a.dart' as lib;
import 'b.dart' as lib;

void main() {
  lib.Foo();
}

Even though Foo comes from b.dart when you CTRL + Click lib. before it, it moves the cursor for line 1 (import 'a.dart' as lib;).

I'd expect it to show the second line (for b.dart) or if both imports have that element for it to show a peek window to see all imports and select which you want (or default to this if there is nothing after the prefix).

This is a bad behaviour specially when there are multiple imports between the two (or more) that have the alias and you can't see them.


CC: @DanTup

dart-github-bot commented 1 month ago

Summary: The issue is that when using CTRL + Click on an alias defined multiple times in different imports, the IDE incorrectly navigates to the first import instead of the correct one or providing a peek window to choose between them. This behavior is problematic when multiple imports exist between the relevant ones, making it difficult to locate the correct source.

FMorschel commented 1 month ago

As a reference, this came from a talk about https://github.com/dart-lang/sdk/issues/32735