дзеркало
https://github.com/l0ng-ai/openidea.git
синхронізовано 2026-12-03 16:51:16 +02:00
fix(lsp): answer a server's own configuration section with its own settings block (#7611)
A server's Workspace Configuration never reached Intelephense: it asks workspace/configuration for its own section (`intelephense`) and takes the answer as its settings, but the handler only looked for that section under a `settings` key. The configuration editor saves the wrapped form (`{"intelephense": {...}}`), so the server got the whole configuration wrapped again and ignored files.maxSize, exclusions and the rest. The server's own section now also resolves to a top-level block of the same name; dotted sub-sections and the empty section are unchanged.
Closes #7609
Co-authored-by: Inf1mum <[email protected]>
Цей коміт міститься в:
1 джерело
797904c308
коміт
2f3f08efde
2 files changed
+37
-4
No files matched your search
@@ -563,10 +563,15 @@ impl ClientHandler {
|
||||
// vtsls asks for the whole configuration as section `""`.
|
||||
.map(|item| match item.get("section").and_then(Value::as_str).filter(|s| !s.is_empty()) {
|
||||
// The server's own section: its block under `settings` (basedpyright asks
|
||||
// `basedpyright` and `basedpyright.analysis`), else the options themselves.
|
||||
Some(section) if section == self.server.name => {
|
||||
options.get("settings").and_then(|s| s.get(section)).unwrap_or(&options).clone()
|
||||
}
|
||||
// `basedpyright` and `basedpyright.analysis`), or the block of the same
|
||||
// name at the top (the wrapped form the editor saves:
|
||||
// `{"intelephense": {...}}`), else the options themselves (#7609).
|
||||
Some(section) if section == self.server.name => options
|
||||
.get("settings")
|
||||
.and_then(|s| s.get(section))
|
||||
.or_else(|| options.get(section))
|
||||
.unwrap_or(&options)
|
||||
.clone(),
|
||||
// Servers that take settings under `initializationOptions.settings`
|
||||
// (jdtls) ask for the same sections later.
|
||||
Some(section) => [&options, options.get("settings").unwrap_or(&Value::Null)]
|
||||
|
||||
@@ -3013,6 +3013,34 @@ async fn eslint_configuration_includes_workspace_folder() {
|
||||
assert_eq!(other, json!([{ "flag": true, "nested": { "deep": 1 } }]));
|
||||
}
|
||||
|
||||
/// The server's own section is answered with its own settings block, not with the whole
|
||||
/// configuration wrapped again: Intelephense asks `intelephense` and reads `files` and
|
||||
/// `environment` off the answer, and the Workspace Configuration editor saves the
|
||||
/// settings under the server's name (`{"intelephense": {...}}`) (#7609).
|
||||
#[tokio::test(flavor = "multi_thread")]
|
||||
async fn the_server_s_own_section_is_answered_with_its_own_block() {
|
||||
let h = harness_configured("mock", "mk", &[("mock", incremental_caps())], |cfg| {
|
||||
cfg.settings = Some(json!({ "mock": { "files": { "maxSize": 5000000, "exclude": ["**/var/**"] } } }));
|
||||
});
|
||||
h.open("a.mk", "x");
|
||||
h.wait_status("mock", ServerStatus::Ready).await;
|
||||
let state = h.launcher.state("mock");
|
||||
let items = json!({ "items": [{ "section": "mock" }, { "section": "mock.files" }, { "section": "" }] });
|
||||
let answer: Value = state.peer().request("workspace/configuration", items, None).await.unwrap();
|
||||
assert_eq!(answer[0], json!({ "files": { "maxSize": 5000000, "exclude": ["**/var/**"] } }));
|
||||
// A dotted sub-section is looked up inside the wrapped block.
|
||||
assert_eq!(answer[1], json!({ "maxSize": 5000000, "exclude": ["**/var/**"] }));
|
||||
// An empty section still names the whole configuration (merged with the defaults).
|
||||
assert_eq!(
|
||||
answer[2],
|
||||
json!({
|
||||
"flag": true,
|
||||
"mock": { "files": { "maxSize": 5000000, "exclude": ["**/var/**"] } },
|
||||
"nested": { "deep": 1 },
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
#[tokio::test(flavor = "multi_thread")]
|
||||
async fn settings_changes_reach_servers_without_restarts() {
|
||||
let h = harness(&[("mock", incremental_caps()), ("extra", incremental_caps())]);
|
||||
|
||||
Reference in new issue
Заблокувати користувача