vscode-dart-import icon indicating copy to clipboard operation
vscode-dart-import copied to clipboard

Not working with import sorter package

Open ianjaspersantos opened this issue 3 years ago • 1 comments

The extension do not work when working with flutter package "import sorter". The problem is occuring when the dart import extension trying to sort lines with comments in between the imported files..

ianjaspersantos avatar Nov 19 '20 11:11 ianjaspersantos

If you have comments within your imports it gets really hard for this to automatically sort everything right? Dare I say impossible as there can multiple desired outcomes.

Let's say you have:

// group 1
import 'local/file.dart';
import 'package:foo/bar.dart';


// group 2
import 'package:my_package/local/file2.dart';
import 'dart:foo';

The expected result (removing the comments would be):

import 'dart:foo';

import 'package:foo/bar.dart';

import 'local/file.dart';
import 'local/file2.dart';

Where should each comment be put on the new structure? Since every import can change place, I don't see how we can correctly place comments back. If you are using this plugin you are relying on automatically defining the ordering of imports; in that case I think it doesn't make sense to have any comments in your import section. Comments are for humans. This plugin treats your import section as a "generated" part of your code.

luanpotter avatar Feb 23 '21 19:02 luanpotter