aziznal / dart-import-sorter

A vscode extension that groups and sorts imports for dart files (https://marketplace.visualstudio.com/items?itemName=aziznal.dart-import-sorter)
MIT License
15 stars 1 forks source link

Bug: Sort on Save garbles current file when refactoring #65

Open flutterrausch opened 5 months ago

flutterrausch commented 5 months ago

1st: love the ext, love the sort on save feature.

But I had to switch it off - too annoying too often. If I e.g. rename a function, I get a block of imports (most probably the last sorted ones) on top of current file - often leads to a lot of confusing project errors. I can Cmd-Z it away, but it totally breaks my flow.

Here is what I think happens: The refactor does an auto-save itself. Somehow import-sorter is hooked in and applies cached imports. It may only apply, if multiple files get changed thru the refactoring.

Please fix :)

aziznal commented 5 months ago

interesting issue. I've tried to recreate it on my side but wasn't able to. Could you share the exact scenario where you're seeing this behavior?

flutterrausch commented 5 months ago

Hope this helps

malkomich commented 2 months ago

It happens with sortOnSave feature enabled, everytime you refactor a file (renaming, moving to a different folder...)

I can show you an example of the unexpected changes automatically made in one of my files:

Captura de pantalla 2024-05-07 a las 1 05 54

It looks to be adding new "random"(it may follow some logic but I have no clue) imports, replacing the top lines of the file.