Skip to content
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

Ruff-specific source actions are not working with ruff server #10780

Closed
snowsignal opened this issue Apr 4, 2024 · 0 comments · Fixed by #10916
Closed

Ruff-specific source actions are not working with ruff server #10780

snowsignal opened this issue Apr 4, 2024 · 0 comments · Fixed by #10916
Assignees
Labels
bug Something isn't working server Related to the LSP server

Comments

@snowsignal
Copy link
Contributor

VS Code configuration like the following will work as expected:

{
    "[python]": {
      "editor.codeActionsOnSave": {
        "source.organizeImports": "explicit",
      },
    }
}

but this configuration:

{
    "[python]": {
      "editor.codeActionsOnSave": {
        "source.organizeImports.ruff": "explicit",
      },
    }
}

does not work.

The problem here is that when we create the source code action, the kind is always set to source.{fixAll | organizeImports}. Since the client is expected a code action of kind source.{fixAll | organizeImports}.ruff, the code action we return will not get resolved.

@snowsignal snowsignal added the server Related to the LSP server label Apr 4, 2024
@snowsignal snowsignal self-assigned this Apr 4, 2024
@snowsignal snowsignal added the bug Something isn't working label Apr 4, 2024
snowsignal added a commit that referenced this issue Apr 16, 2024
## Summary

Fixes #10780.

The server now send code actions to the client with a Ruff-specific
kind, `source.*.ruff`. The kind filtering logic has also been reworked
to support this.

## Test Plan

Add this to your `settings.json` in VS Code:

```json
{
  "[python]": {
    "editor.codeActionsOnSave": {
      "source.organizeImports.ruff": "explicit",
    },
  }
}
```

Imports should be automatically organized when you manually save with
`Ctrl/Cmd+S`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working server Related to the LSP server
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant