-
Notifications
You must be signed in to change notification settings - Fork 23
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
When both Ruff and isort run on-save, last line of file is repeated #240
Comments
@charliermarsh do both the extensions run the formatting? Can you share the logs from FYI, In the next release of the python extension, we won't be installing |
Yeah I believe they both run. I don't get much from the
I added some very verbose logging to
After the edit, if I hit Command + Z once, I get: import sys
from setuptools import setup
aa If I hit it again, I'm back to: import sys
from setuptools import setup
aa |
My guess is that they're both generating the edit, and trying to apply it to lines 0-to-3 (or rather, start of line 0 to start of line 4). When the "second" formatter runs, the previous last-line is now on line 4, since we inserted a newline between the |
This might actually be a VS Code bug. It should not be running both the import organizers. It should be running only one. The thing is I don't think we are even getting diferent versions here. I suspect we may be getting the same version. |
Closing against microsoft/vscode#174295 |
This may well be a Ruff problem but I'm having trouble understanding it, and it only occurs when both Ruff and isort are installed together, so I thought it was worth raising here.
When both Ruff and isort are installed, and configured to organize imports on save, the last line of the file ends up being repeated on-save.
For example, given:
And this
settings.json
:Then on-save, I get:
Disabling either extension causes the file to format properly.
I think this has to do with the use of
len(document.lines)
to format the "whole file" edit, but I would've thought that the "versioned" edits would avoid this issue.You might decide that this either (1) Ruff's problem, or (2) user error (given that you shouldn't really have two plugins organizing imports), but this does seem like unexpected behavior and possibly indicative of bug in either or both extension.
The text was updated successfully, but these errors were encountered: