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] Stop parsing diagnostics from other sources for code action requests #15373

Merged
merged 1 commit into from
Jan 9, 2025

Conversation

joouha
Copy link
Contributor

@joouha joouha commented Jan 9, 2025

Summary

This PR stops ruff server attempting to parse diagnostic data for diagnostics from other language servers.

The issue

When using ruff server with typos-lsp in helix, it is impossible to apply code actions suggested by typos-lsp.

The cause

During a textDocument/codeAction request, the editor will send Diagnostics to ruff server as part of the codeActionContext - these may have been generated by other LSP servers.

According to the spec, the Diagnostic.data field can contain any data. However, ruff server attempts to parse all contextual diagnostics, and assumes the data field adheres to the data structure used by ruff server.

Since other language servers are free to use their own data structure, parsing the diagnostics fails causing an error, which ultimately causes the code action request to fail.

The fix

On code action requests, ruff server should only parse contextual diagnostics generated by ruff server.

Copy link
Contributor

github-actions bot commented Jan 9, 2025

ruff-ecosystem results

Linter (stable)

✅ ecosystem check detected no linter changes.

Linter (preview)

✅ ecosystem check detected no linter changes.

@MichaReiser MichaReiser added server Related to the LSP server bug Something isn't working labels Jan 9, 2025
Copy link
Member

@MichaReiser MichaReiser left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice. Interesting that the client sends all known Diagnostic but that sort of makes sense.

@MichaReiser MichaReiser merged commit 8628f16 into astral-sh:main Jan 9, 2025
21 checks passed
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 this pull request may close these issues.

2 participants