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 /cli/lsp/diagnostics.rs | |
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 'cli/lsp/diagnostics.rs')
-rw-r--r-- | cli/lsp/diagnostics.rs | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/cli/lsp/diagnostics.rs b/cli/lsp/diagnostics.rs index fd4142fd9..7d8368b27 100644 --- a/cli/lsp/diagnostics.rs +++ b/cli/lsp/diagnostics.rs @@ -1388,6 +1388,7 @@ mod tests { } fn mock_config() -> ConfigSnapshot { + let root_uri = resolve_url("file:///").unwrap(); ConfigSnapshot { settings: Settings { workspace: WorkspaceSettings { @@ -1397,6 +1398,13 @@ mod tests { }, ..Default::default() }, + workspace_folders: vec![( + root_uri.clone(), + lsp::WorkspaceFolder { + uri: root_uri, + name: "".to_string(), + }, + )], ..Default::default() } } @@ -1468,7 +1476,7 @@ let c: number = "a"; specifier.clone(), SpecifierSettings { enable: Some(false), - enable_paths: Vec::new(), + enable_paths: None, code_lens: Default::default(), }, ); |