From 4a11603c76b13ecf92ce3141ec317a42ae9f8d1d Mon Sep 17 00:00:00 2001 From: Nayeem Rahman Date: Fri, 8 Sep 2023 00:50:34 +0100 Subject: refactor(lsp): clean up "enablePaths" handling (#20388) Previously we pre-computed enabled paths into `Config::enabled_paths`, and had to keep updating it. Now we determine enabled paths directly from `Config::settings` on demand as a single source of truth. Removes `Config::root_uri`. If `InitializeParams::rootUri` is given, and it doesn't correspond to a folder in `InitializeParams::workspaceFolders`, prepend it to `Config::workspace_folders` as a mocked folder. Includes groundwork for https://github.com/denoland/vscode_deno/issues/908. In a minor version cycle or two we can fix that in vscode_deno, and it won't break for Deno versions post this patch due to the corrected deserialization logic for `enablePaths`. --- test_util/src/lsp.rs | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) (limited to 'test_util') diff --git a/test_util/src/lsp.rs b/test_util/src/lsp.rs index 5369d6361..d276e3ed3 100644 --- a/test_util/src/lsp.rs +++ b/test_util/src/lsp.rs @@ -591,6 +591,7 @@ impl LspClientBuilder { writer, deno_dir, stderr_lines_rx, + config: json!("{}"), supports_workspace_configuration: false, }) } @@ -605,6 +606,7 @@ pub struct LspClient { deno_dir: TempDir, context: TestContext, stderr_lines_rx: Option>, + config: serde_json::Value, supports_workspace_configuration: bool, } @@ -699,21 +701,14 @@ impl LspClient { }; self.write_request("initialize", params); self.write_notification("initialized", json!({})); + self.config = config; if self.supports_workspace_configuration { - self.handle_configuration_request(config); + self.handle_configuration_request(self.config.clone()); } } pub fn did_open(&mut self, params: Value) -> CollectedDiagnostics { - self.did_open_with_config( - params, - json!([{ - "enable": true, - "codeLens": { - "test": true - } - }]), - ) + self.did_open_with_config(params, self.config.clone()) } pub fn did_open_with_config( -- cgit v1.2.3