1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2025-01-18 11:53:59 -05:00

fix(lsp): ensure enablePaths works when clients do not provide a trailing slash for workspace dir (#18373)

Closes https://github.com/denoland/vscode_deno/issues/827
This commit is contained in:
David Sherret 2023-03-22 21:58:38 -04:00 committed by GitHub
parent f69e4794d2
commit 64f491422b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 133 additions and 121 deletions

View file

@ -377,7 +377,7 @@ impl LanguageServer {
let mut ls = self.0.write().await;
if let Ok(configs) = configs_result {
for (value, internal_uri) in
configs.into_iter().zip(specifiers.into_iter().map(|s| s.1))
configs.into_iter().zip(specifiers.into_iter().map(|s| s.0))
{
match value {
Ok(specifier_settings) => {

View file

@ -928,6 +928,7 @@ fn lsp_inlay_hints_not_enabled() {
#[test]
fn lsp_workspace_enable_paths() {
fn run_test(use_trailing_slash: bool) {
let context = TestContextBuilder::new().build();
// we aren't actually writing anything to the tempdir in this test, but we
// just need a legitimate file path on the host system so that logic that
@ -943,7 +944,14 @@ fn lsp_workspace_enable_paths() {
.set_enable_paths(vec!["./worker".to_string()])
.set_root_uri(root_specifier.clone())
.set_workspace_folders(vec![lsp::WorkspaceFolder {
uri: root_specifier.clone(),
uri: if use_trailing_slash {
root_specifier.clone()
} else {
ModuleSpecifier::parse(
root_specifier.as_str().strip_suffix('/').unwrap(),
)
.unwrap()
},
name: "project".to_string(),
}])
.set_deno_enable(false);
@ -1065,6 +1073,10 @@ fn lsp_workspace_enable_paths() {
);
client.shutdown();
}
run_test(true);
run_test(false);
}
#[test]