Open Mike278 opened 1 year ago
[...] (I haven't tested this in any other editor)
I should have! This works as expected in VSCode.
Interestingly if I rename foo.dart
to zzz.dart
the order flips, so IntelliJ is sorting it alphabetically somewhere.
The ordering of completion suggestions produced by the analysis server is taken as "advice" from most editors / IDEs. We can't change the behavior of the editors, so there's probably nothing we can do to improve this situation.
Looks like this might be the API to do it for IntelliJ?
Alternatively, what if the "Import Library" correction also took into account other preferences like avoid_relative_lib_imports
or always_use_package_imports
? If it could be configured such that there's only ever one correction in the list then the order doesn't matter.
... what if the "Import Library" correction also took into account other preferences ...
That's a direction we're definitely interested in moving toward. We have started using lint enablement to control some other code generation styles (fixes, iirc), and should do so here as well.
Dart SDK version: 3.3.0-48.0.dev (dev) (Fri Oct 20 09:02:07 2023 -0700) on "windows_x64"
Steps to reproduce:
analysis_options.yaml
withlib/foo.dart
with contentsconst hello = 'world';
lib/bar.dart
with contentsconst greeting = hello;
lib/bar.dart
, place the cursor onhello
, and generate suggestions with alt+enterImport library 'package:import_bug/foo.dart'
is the first (and ideally, only) suggestionThis function seems to suggest the order depends on the value of
prefer_relative_imports
, but changing this value doesn't change the order.Might be related to https://github.com/dart-lang/sdk/issues/32916 where support for relative imports was added?