koxudaxi / ruff-pycharm-plugin

PyCharm plugin for ruff. This plugin provides reformat code using ruff.
MIT License
173 stars 6 forks source link

Project setting related to actions on save is not respected when two projects are open #438

Open mrezzamoradi opened 1 month ago

mrezzamoradi commented 1 month ago

Describe the bug Each project's setting should be respected even if both projects are opened in the same window.

I have two projects which one of them is formatted with ruff and want to continue to do so (project A), and the other one is not formatted by ruff and I don't want it to get formatted by ruff (project B). I have enabled the setting for project A to "Run ruff when the python file is saved" but disabled it for project B. When I open project B alone, it works as expected. However if I open project A alongside it in the same window, then the files in project B gets formatted by ruff on save.

To Reproduce Steps to reproduce the behavior:

  1. Prepare two projects (A and B), A formatted with ruff and B that is not formatted with ruff.
  2. Enable the setting to "Run ruff when the python file is saved" for A and disable it for B.
  3. Open both projects in Pycharm.
  4. Try to edit a file on project B and save the file. The file gets formatted by ruff.

Expected behavior The edited file of project B shouldn't get formatted by ruff on save.

Screenshots Project A: image image

Project B: image image

Environments (please complete the following information):

Additional context I'm using pyenv to manage python environment, but those projects are using different pyenv environments.

rh-sp commented 4 days ago

Related (if not the same): the setting "Exclude files outside of the project" only applies to the "main" project, i.e., if activated, files in the second project will be excluded, regardless of that project's settings.

(Disabling the setting isn't an option for me, because then it will also reformat files in the git staging area, which I don't want)