-
Notifications
You must be signed in to change notification settings - Fork 645
Cursor jump unexpectedly #1346
Comments
I have the same issue as you, I also used vscode-go and vscode-vim. But when I modified the user settings |
@zhao-kun Thank you very much! |
This is weird. The only thing happening on save that can move stuff around is the formatting feature. I can repro the case when the cursor moves to the next line, but not the case when the cursor moving to the bottom of the file. Can either of you provide a small sample code with repro steps for when you see the cursor going to the end of the file? |
I have pushed the fix for the issue that I see i.e cursor jumping to the next line. Can either of you test it and see if it solves your case as well? All you have to do is
|
Scratch that. I can repro the case when the cursor jumps to the last line. The root cause is due to changes in the core api. I'll dig around a little more and get back here. |
@ramya-rao-a I tried your extension but the problem still exists. I did more test and found cursor will certainly jump to end of file after saving, no matter which way I use (click save button, press ctrl+s, or use vim command :w) |
@maxint64 Thanks. I found today that the root cause is with the way edits are applied by VS Code. Something changed between VS code 1.17 and 1.18 release. Until then, the work around is to either disable the format on save feature or the auto save feature. |
@ramya-rao-a Just a quick hint that after your changes introduced in 89e1a18 the curser no longer moves to the end but to the beginning of the file when formatting-on-save. |
@Xjs I know... Its a temporary fix. I figured cursor moving to start of the same line is a just a little bit less annoying than it moving to the end of the file. Previously, the edits being applied were multi line edits The right fix would require us to apply edits only for the part of the line that needs the change which is slightly more complicated as the Go tools only return diffs at line level |
any updates on this guys? I had to scroll back up to the line where I am editing on a Go file with like 1k lines.. |
@Hokutosei Update to the latest version of the Go extension (0.6.69). The cursor wouldn't go to end of file, but to the start of the line on save if formatting changes exist. Other workaround is to disable the format on save feature until we get a complete fix for this issue |
I have already up to the latest verion of Go extension(0.6.69), but the cursor still go to end of file. |
@ramya-rao-a oh god..I have updated it already to 0.6.69 . I guess I have to wait for the fix. currently, I am editing somewhere on 500th line, and hit save, my cursor will go to top (not start of the line) and click back again to where I am editing.. why is this even happening? before, I did not have any problems. I can't disable formatting on save this time. this is part of my workflow.. thanks for the help btw.. looking forward for the fix. |
The root cause is that there has been a change in VSCode in the way it treats the edits returned by extensions. If extension returns an edit/edits across contiguous group of lines, the cursor moves to the last line of this group. This was what was happening in Go 0.6.68 You can see the upstream issue at microsoft/vscode#38728 For Go 0.6.69 I made a change so that the extension returns one edit per line instead of one edit per contiguous group of lines. I would strongly suggest disabling format on save and run formatting manually once in a while |
sorry but any fix on this? as far as I am looking on the upstream issue, there seems to be no fix unless the author of this plugin fix the formatting issue that VSCode created. first, this should have not been a problem if VSCode did not change the way it treats the edits. so now what,. disable the format:onSave? maybe no. this was a good plugin, it helped me alot and many others I would suppose. |
VS Code did change the way it treats edits.
We are close to releasing the next update for VS Code, therefore I was busy and couldn't devote much time to this issue or the Go extension. But, now I am working on this as we speak. The fix requires the Go extension to enable running formatting tools on the file contents (pass via stdin) instead of saving the file and then running the tools on the file on disk. The formatting tools ( After my investigations today, I found that the use of the new flag Long story short, you can expect a fix soon. I'll try for end of week.
Until the fix, you can disable the format on save feature and run format manually when needed |
@ramya-rao-a accepted. sorry for the rant. I am looking forward for the fix, and yeah I guess I'll be waiting until next week maybe..hopefully. thank you again for the help. |
@Hokutosei and others on this thread, I have the fix ready, can you help me with testing? You will have to
Issues #613 and #630 will still exist if you use |
^ looks like that fixed it, though the install command didn't work for me (on Windows), it just launched Code without installing the tool. I followed these steps to be sure:
It then appears to be fixed. Thanks so much for this :) |
Oh sorry, there was a typo there. It should be
Awesome! |
@ramya-rao-a sorry for the super late reply. I have tried your fix
updated my settings, and I am glad to report to you that it fixed the problem. I am glad I don't have to scroll back again up/down from a huge Go file. thank you so much :) |
I'm getting the following error
|
@julianfrank I've seen that issue for a few users on Linux. Clone the vscode-go repo and get the file from there. |
I'm on Windows 10 home ... Do I still need to use the clone and compile? |
You don't need compile. Just clone and use the |
Can also confirm that the Go-latest.vsix installation and config change fixed the issue for me. Woohoo! :) |
The latest update to the Go extension (0.6.70) has this fix. Thanks for the patience everyone! |
Thank you very much for your excellent work! I have just upgraded the extension :-) |
Thank you! |
The whole jumping has stopped for me.... Thanks |
After the latest update of vscode-go, I found my cursor would move unexpectedly, the cursor might jump to end of line or bottom of file suddenly when I'm coding. I use vscode-go and vscode-vim together, and the problem appears more frequently when I move cursor past a bracket (including (), {}, []).
I guess there may be something conflict. I close vscode-vim and open vscode-go, cursor move unexpectedly yet. When I close vscode-go and keep using vscode-vim, everything is ok. It's very strange.
Thank you for any suggestion!
The text was updated successfully, but these errors were encountered: