diff options
author | Nayeem Rahman <nayeemrmn99@gmail.com> | 2023-09-08 00:50:34 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-09-08 00:50:34 +0100 |
commit | 4a11603c76b13ecf92ce3141ec317a42ae9f8d1d (patch) | |
tree | 00718c6131da9cd353335731ea78e37ca5ce5e92 /test_util/src | |
parent | 9d6584c16f8c759f321ab82a3b9d03d0e2e1d363 (diff) |
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`.
Diffstat (limited to 'test_util/src')
-rw-r--r-- | test_util/src/lsp.rs | 15 |
1 files changed, 5 insertions, 10 deletions
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<mpsc::Receiver<String>>, + 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( |