Skip to content

Commit 075b3be

Browse files
authored
Merge pull request #21297 from osdyne/fix-lsp-configuration-request
fix: Fix LSP configuration request handling
2 parents e2fea49 + e1c9eac commit 075b3be

1 file changed

Lines changed: 16 additions & 9 deletions

File tree

editors/code/src/client.ts

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,17 +30,24 @@ export async function createClient(
3030
},
3131
async configuration(
3232
params: lc.ConfigurationParams,
33-
token: vscode.CancellationToken,
34-
next: lc.ConfigurationRequest.HandlerSignature,
33+
_token: vscode.CancellationToken,
34+
_next: lc.ConfigurationRequest.HandlerSignature,
3535
) {
36-
const resp = await next(params, token);
37-
if (resp && Array.isArray(resp)) {
38-
return resp.map((val) => {
39-
return prepareVSCodeConfig(val);
40-
});
41-
} else {
42-
return resp;
36+
// The rust-analyzer LSP only ever asks for the "rust-analyzer"
37+
// section, so we only need to support that. Instead of letting
38+
// the vscode-languageclient handle it, use the `cfg` property
39+
// in the config.
40+
if (
41+
params.items.length !== 1 ||
42+
params.items[0]?.section !== "rust-analyzer" ||
43+
params.items[0]?.scopeUri !== undefined
44+
) {
45+
return new lc.ResponseError(
46+
lc.ErrorCodes.InvalidParams,
47+
'Only the "rust-analyzer" config section is supported.',
48+
);
4349
}
50+
return [prepareVSCodeConfig(config.cfg)];
4451
},
4552
},
4653
async handleDiagnostics(

0 commit comments

Comments
 (0)