ruff server: Fix multiple issues with Neovim and Helix#11497
Merged
snowsignal merged 2 commits intomainfrom May 22, 2024
Merged
ruff server: Fix multiple issues with Neovim and Helix#11497snowsignal merged 2 commits intomainfrom
ruff server: Fix multiple issues with Neovim and Helix#11497snowsignal merged 2 commits intomainfrom
Conversation
Contributor
|
charliermarsh
approved these changes
May 22, 2024
dhruvmanila
reviewed
May 27, 2024
Comment on lines
-133
to
+134
| settings: Option<ClientSettings>, | ||
| #[serde(flatten)] | ||
| settings: ClientSettings, |
Member
There was a problem hiding this comment.
@snowsignal when you're back, can you explain why is this being flattened? This is causing #11507 because now it's not under settings but rather in the global table.
Member
There was a problem hiding this comment.
Ok, I understand why it was flattened - to account for the empty initialization options. I think we need to re-think about how to handle these cases.
dhruvmanila
added a commit
that referenced
this pull request
May 27, 2024
…ed (#11566) ## Summary This PR fixes the bug to avoid flattening the global-only settings for the new server. This was added in #11497, possibly to correctly de-serialize an empty value (`{}`). But, this lead to a bug where the configuration under the `settings` key was not being read for global-only variant. By using #[serde(default)], we ensure that the settings field in the `GlobalOnly` variant is optional and that an empty JSON object `{}` is correctly deserialized into `GlobalOnly` with a default `ClientSettings` instance. fixes: #11507 ## Test Plan Update the snapshot and existing test case. Also, verify the following settings in Neovim: 1. Nothing ```lua ruff = { cmd = { '/Users/dhruv/work/astral/ruff/target/debug/ruff', 'server', '--preview', }, } ``` 2. Empty dictionary ```lua ruff = { cmd = { '/Users/dhruv/work/astral/ruff/target/debug/ruff', 'server', '--preview', }, init_options = vim.empty_dict(), } ``` 3. Empty `settings` ```lua ruff = { cmd = { '/Users/dhruv/work/astral/ruff/target/debug/ruff', 'server', '--preview', }, init_options = { settings = vim.empty_dict(), }, } ``` 4. With some configuration: ```lua ruff = { cmd = { '/Users/dhruv/work/astral/ruff/target/debug/ruff', 'server', '--preview', }, init_options = { settings = { configuration = '/tmp/ruff-repro/pyproject.toml', }, }, } ```
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #11236.
This PR fixes several issues, most of which relate to non-VS Code editors (Helix and Neovim).
Test Plan
I've tested to confirm that each issue has been fixed.
isolated_config.mov
empty_diagnostics.mov
cwd_workspace.mov