Skip to content

[ruff] Stop parsing diagnostics from other sources for code action requests#15373

Merged
MichaReiser merged 1 commit intoastral-sh:mainfrom
joouha:parse-own-diagnostics
Jan 9, 2025
Merged

[ruff] Stop parsing diagnostics from other sources for code action requests#15373
MichaReiser merged 1 commit intoastral-sh:mainfrom
joouha:parse-own-diagnostics

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.

@github-actions
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