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`.
This commit is contained in:
Nayeem Rahman 2023-09-08 00:50:34 +01:00 committed by GitHub
parent 9d6584c16f
commit 4a11603c76
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 264 additions and 245 deletions

View file

@ -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(),
},
);