-
Notifications
You must be signed in to change notification settings - Fork 30.2k
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
Multiple Import Organizers results in corrupted code #174295
Comments
@karthiknadig Have you tried putting together a minimal example to prove this is a VS Code issue? If the extensions are well behaved, the actions will be run sequentially |
@karthiknadig Try creating a minimal example extension to figure out what the root cause is and provide easier steps to reproduce it. You can use https://github.com/microsoft/vscode-extension-samples/tree/main/code-actions-sample as a starting point |
@mjbvz I just wanted to clarify that this is a LSP scenario not a case where we use I have added detailed logs. If things were working as you say, then there should have been a Lets assume LSP logs from isort
LSP logs from ruff
|
It will be much easier to understand the problem with a minimal, self-contained example . Can you please try putting one together using our extension sample code: https://github.com/microsoft/vscode-extension-samples/tree/main/code-actions-sample |
I have created a repo https://github.com/karthiknadig/organize1 Repro steps:
Actual: Expected: |
This issue has been closed automatically because it needs more information and has not had recent activity. See also our issue reporting guidelines. Happy Coding! |
I experienced this too: microsoft/vscode-black-formatter#220 When both isort and ruff organize imports then somehow the last lines at the bottom of the file get duplicated. That may be black doing it, I'm still not sure. |
I am also affected by this problem (with black and isort). |
I just spent over an hour trying to find out why the file would change on every save. I have isort set to leave two blank lines after formatting. So on one Sort Imports run, isort would do nothing and Ruff would remove one line. On another run, isort would add a line and Ruff would do nothing (this also proves that both formatters get the same file). The only way to make this go away was to disable organised imports. Then I found out (by scrubbing through isort release notes) that Ruff formats imports as well (I did not know that initially, as it is enabled by default). There is NO indication whatsoever that multiple handlers of |
This is such a pernicious bug. Just found a bunch of weeks-old commits in our codebase with final line repeated. Having read this issue a couple of months ago, I had promptly disabled |
Just to say I'm experiencing this (ruff and isort) I have gone round the issue by disabling the ruff sorter using |
Type: Bug
Use two LSP servers have them both register provider of Organize Import code Action for the same language. When user runs Organize Imports both LSP servers receive the same version of the doc.
Repro steps:
You will need both
isort
andruff
extensions.See here: microsoft/vscode-isort#240 (comment)
VS Code version: Code 1.75.1 (441438a, 2023-02-08T21:32:34.589Z)
OS version: Windows_NT x64 10.0.19045
Modes:
Sandboxed: No
System Info
canvas_oop_rasterization: disabled_off
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
multiple_raster_threads: enabled_on
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
skia_renderer: enabled_on
video_decode: enabled
video_encode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: disabled_off
Extensions (24)
A/B Experiments
The text was updated successfully, but these errors were encountered: