Closed sQVe closed 5 years ago
This is weird, I use that feature too but I haven't experienced this issue, if you set it to false it does not happen? I didn't understood that part.
In any case, version of visual studio you're using would be helpful.
Hello,
I have the same issue, I use the latest version of VS Code (1.18.0
). It is a bit weird, for example I don't have this problem with the Prettier extension even though it reformats the whole file.
Same issue here, I also use Prettier which doesn't have this issue. I'm also on the latest version of VS Code (1.18.0
).
I'm running VSCode Version : 1.18.0-3
. I cannot replicate this issue when triggering sort via a Ctrl + Shift + P
or a keybind.
Seems like editorconfig
had this problem too but solved it: https://github.com/editorconfig/editorconfig-vscode/issues/40. I would love to help out and investigate this myself but I'm currently incredibly tight on time...
Yep, I can reproduce the issue now, it happens to me since VSCode updated. I'll try to debug it but I haven't much time, any help would be appreciated here.
I'm also hitting this. Was hitting it in the other deprecated sort imports, swapped to this one, still seeing it.
If my old (deprecated) extension also shows this behavior then there might have been an update in the behavior of Visual Studio Code with one of the new versions. I'm also seeing this sadly :/
Seeing it too.
Same problem here...
Same here :(
Yeah, I still have this issue and it's getting annoying, no change was made lately so it's probably a new Visual Studio version as @peterjuras says so I don't know where to start to fix it.
Any update for this? It's been 3 months now and I'd love to be able to use this plugin again. In its current state it's unusable.
@jessejanderson The last update is the one I wrote last week, the previous comment.
I still using the plugin, it's annoying but I can live with it. For me it's way better than sorting imports manually. If you find time to fix the issue with a PR we'll be more than happy to finally close it.
BTW guys, you can just add a +1 to the first post in this thread. We don't want to clutter it with "me too" messages so it will be easier to spot the important information to solve this bug.
This comment explains the "right" way to format a document:
@Stijnkool The recommendation is to register a format provider for the language. Then, when users configure editor.formatOnSave to true, your format provider will be invoked for the text document that will be saved. Then, the edits you return will be diffed against the current text, and a minimal set of edits will be computed and applied. Thus, if your formatter gives a replace-entire-file with new content edit, the edit will be broken up and markers (including the cursor) will survive.
I don't know if this is what this extension do.
That's exactly not what this library is doing. Thanks @dorian-marchal , I'll try that on Monday 👍
I'm looking how this extension can register as a Document Formatter Provider but as the operations are made by import-sort
it returns a ICodeChange[]
and VSCode expects a TextEdit[]
which is quite different.
I've pushed the progress into a branch in case you want to take a look at it.
Will probably resume it in a few days.
@amatiasq I think making thing extension as formatter might be not the best idea right now because vscode doesn't allow to have multiple formatters simultaneously: https://github.com/Microsoft/vscode/issues/33477 https://github.com/Microsoft/vscode/issues/41882
This means user would have to choose for JS between sort-imports and prettier for example...
Yeah, that changes the situation, I assumed formatters would run sequentially. I guess the branch is garbage now.
Is there any way to run Prettier and import-sort in a single command?
@OliverJAsh How is that related to this issue?
@sQVe I was linked here from #15 and there's talk of how multiple formatters work in VSCode.
The relation is than we were discussing about making import-sort
a formatter here.
The question is indeed unrelated, and in any case the answer is no, import-sort
is not related to Prettier in any way so there is no command to run both.
I have the same issue. Found out that this issue is sort import plugin issue throug prettier issues - https://github.com/prettier/prettier-vscode/issues/409
Linking it for future preference
Any progress on this? I've disabled the plugin as it's untenable with the current behaviour
This issue comes from an update in VSCode, I've been researching it but haven't been able to find how to stop it. I'm still using the plugin to be honest, the benefit it brings to my projects is bigger than the inconvenience caused by this issue to me.
Any help with this issue is welcome.
I've been plagued by this cursor moving issue for months and months. Finally found that this plugin is the cause, so I've disabled it until there's a solution. When I get some time I'll debug this in vscode and see if I can assist with a fix, fingers crossed. I love the plugin, so I'm hoping a solution is possible.
The keybinding is no good IMO, I need everyone to have auto sort and format in the team to reduce git differences.
My feeling is that given sort on save is the default, I think there needs to be a warning on the description of this extension whilst the issue persists.
@two-bridges that's a good point, I'll add it to the README.
If you can debug it I'll be glad, I couldn't find the source for this issue and can't spend more time on it.
About the keybinding, I don't use it at all, I have sort-imports.on-save
enabled.
cool @amatiasq. I'll take a look in the next few days on a quiet evening
@two-bridges Did you find time to check it? how can I help you?
I've resolved the issue with PR #34.
If I use
"sort-imports.on-save": true
my cursor jumps to the bottom of the file on each save. This is incredibly annoying and has forced me to leave format on save and opt for a key bind instead.I've disabled all other formatting related extensions and the issue still occurs when
sort-imports
is enabled. Give me a ping if you need further information, I'm happy to help.