-
Notifications
You must be signed in to change notification settings - Fork 37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
formatOnSave scrolls away from current line on save #290
Comments
Can you provide an example code or video/gif of the issue? |
Recording.2023-08-07.232144.mp4Note I have relative line numbers. I hit save, it scrolls me down 30 lines, then I have to manually scroll back up to where I was. |
I have this too. It seems to happen only if you have this in your "editor.codeActionsOnSave": {
"source.organizeImports": true
},
"editor.formatOnSave": true, The two actions conflict and change the file twice, causing the number of lines to change twice and the scrollbar to shift down by that number of lines. 2023-09-10_23-00-03.mp4 |
Duplicate of #118 |
This seems different from #118 - the issue is not the caret moving, the caret stays in the same place but the window scrolls away from the caret. |
This extension actually does not control the UI, all it does is send back a diff in the form of The issue is with the diff itself that we are sending back from the server. Currently, we get the fully formatted content of the file from |
So the issue should be re-opened, right? Also the problem is only reproducible when |
No. The solution to #118 and this are the same, from this extensions perspective. We need to provide narrow text edits.
The fix to generate narrow edits has to be propagated to the import organizer as well. I will be adding this fix to |
FYI, this is still an issue, and the upstream bug has been open since 2018. Since they're probably never going to fix it, can we work around it? |
@emchristiansen We provided a mitigation for most scenarios. Please create a bug with a specific case that does not work. IT could likely be an editor bug. You can also try |
Hey @karthiknadig, Thanks for the quick response! I took your suggestion to try Ruff, and it is fantastic so far - I doubt I'll use Black again. |
@emchristiansen Ruff extension uses the same extension template as this one. The only difference is that |
With formatOnSave enabled, every time I save, my code gets formatted, but the editor window is scrolled down to a seemingly random location, so I have to scroll back up to find the line I was working on every time I save.
I'm using version v2023.4.1 of the extension and this is my full settings.json:
The text was updated successfully, but these errors were encountered: