sdk
sdk copied to clipboard
[pkg/analysis_server] Sort imports fix - issue with multi-line import
Applying sort imports fix when there's an import statement that spans across two lines does not work properly:
https://github.com/dart-lang/sdk/assets/46427323/ce45d8a8-b0dc-4cd2-aaf2-56cf971b467e
Code Sample:
The code sample is for reproduction purposes. In reality, this is an issue with long paths where the formatter would move the show combinator to the next line if the import statement exceeds the specified formatting length.
import 'dart:math';
import 'dart:collection'
show HashMap;
p.s. please advice if this is Dart Code issue and I will transfer the issue there.
Dart SDK version: 3.2.3 (stable) (Tue Dec 5 17:58:33 2023 +0000) on "macos_x64"
Thanks for the report. This is the correct repo for reporting the issue.
@osaxma , I am unable to reproduce the issue with the given example. Sorts fine for me.
https://github.com/dart-lang/sdk/assets/2192312/76448024-c05d-40ed-9fc0-a95caec1acb7
Hi @keertip
The fix in question is Sort Imports which would appear under "Quick Fix" (by clicking the light bulb or "command + dot").
I was not aware of Organize Imports but that seems to work fine (tho it deletes unused imports unlike sort imports).
@osaxma, I do not see an option Sort Imports in the quick fix menu, either from the light bulb or command+dot. Is there anything else in your setup that's unique?
Oops! I've always thought the "Sort Imports" is part of the Dart Code Extension but apparently it comes from from Dart Data Class Generator extension.
Sorry about that!