astral-sh / ruff-vscode

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

Enable fix/formatting commands for Python and Jupyter Notebook files only #487

Closed snowsignal closed 4 weeks ago

snowsignal commented 4 weeks ago

Summary

Fixes https://github.com/astral-sh/ruff/issues/11744.

The extension would allow commands like ruff.applyAutofix to run on any file, even non-Python files. This PR adds a command palette filter so that these commands only appear in the palette when working with Python or Jupyter Notebook files.

Test Plan

Ensure that commands like Ruff: Fix all auto-fixable problems still appear in the command palette (Ctrl/Cmd + Shift + P) for files with the following extensions:

Then, ensure that these commands do not appear for other kinds of files (for example: *.toml or *.json). Ruff: Restart server should still be available.