astral-sh / ruff-vscode

A Visual Studio Code extension with support for the Ruff linter.
Other
945 stars 45 forks source link

Ruff in vscode deletes some of my files when I press `ctrl-s`, and "on-type" setting is enabled #461

Closed melund closed 2 months ago

melund commented 2 months ago

Ruff in vscode deletes some of my files when I press ctrl-S. Here is a small video showing it.

https://github.com/astral-sh/ruff-vscode/assets/1038978/aa5d9d32-64c2-4b2d-9043-8096f35d2994

I press "Enter" a few times, then "Ctrl-s". Then the file is then cleared. Afterwards I need to press "ctrl-z" two times to undo, and then repeat to trigger the issue again.

Changing settings in vs-code from "On-type" to "On-save" seems to fix the problem for me.

zanieb commented 2 months ago

Hi! Sorry about that. Are you on the latest version of everything?

dhruvmanila commented 2 months ago

Also, can you confirm if you're on the pre-release version or the stable version of the extension. If you're on pre-release, then are you using the new ruff server?

charliermarsh commented 2 months ago

Do you have any other extensions alongside Ruff that modify code? E.g., do you have the isort extension installed? There are some bugs in VS Code itself around this.

melund commented 2 months ago

Also, can you confirm if you're on the pre-release version or the stable version of the extension. If you're on pre-release, then are you using the new ruff server?

I was on the default version: v2024.20.0

Do you have any other extensions alongside Ruff that modify code? E.g., do you have the isort extension installed? There are some bugs in VS Code itself around this.

I did actually have the isort extension without being aware of it. It probably came with microsoft's python extension bundle. I have removed those things, and ensured that the ruff extension uses it own 'bundled' ruff version.

melund commented 2 months ago

I have tried a lot to see if I could figure out what really triggered it. But no success. Fell free to close the issue.

zanieb commented 2 months ago

A Charlie mentioned it's a known issue that VSCode will delete file contents when multiple plugins attempt to apply changes. Sounds like you've got it sorted out now! Thanks for investigating.