Skip to content

Commit

Permalink
fix(lsp): don't skip dirs with enabled subdirs (#27580)
Browse files Browse the repository at this point in the history
  • Loading branch information
nayeemrmn authored Jan 7, 2025
1 parent 8cda4cf commit b5e4a30
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
3 changes: 2 additions & 1 deletion cli/lsp/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -853,7 +853,8 @@ impl Settings {
Some(false)
} else if let Some(enable_paths) = &enable_paths {
for enable_path in enable_paths {
if path.starts_with(enable_path) {
// Also enable if the checked path is a dir containing an enabled path.
if path.starts_with(enable_path) || enable_path.starts_with(&path) {
return Some(true);
}
}
Expand Down
7 changes: 7 additions & 0 deletions cli/lsp/language_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4005,12 +4005,14 @@ mod tests {
temp_dir.write("root1/target/main.ts", ""); // no, because there is a Cargo.toml in the root directory

temp_dir.create_dir_all("root2/folder");
temp_dir.create_dir_all("root2/folder2/inner_folder");
temp_dir.create_dir_all("root2/sub_folder");
temp_dir.create_dir_all("root2/root2.1");
temp_dir.write("root2/file1.ts", ""); // yes, enabled
temp_dir.write("root2/file2.ts", ""); // no, not enabled
temp_dir.write("root2/folder/main.ts", ""); // yes, enabled
temp_dir.write("root2/folder/other.ts", ""); // no, disabled
temp_dir.write("root2/folder2/inner_folder/main.ts", ""); // yes, enabled (regression test for https://github.com/denoland/vscode_deno/issues/1239)
temp_dir.write("root2/sub_folder/a.js", ""); // no, not enabled
temp_dir.write("root2/sub_folder/b.ts", ""); // no, not enabled
temp_dir.write("root2/sub_folder/c.js", ""); // no, not enabled
Expand Down Expand Up @@ -4051,6 +4053,7 @@ mod tests {
enable_paths: Some(vec![
"file1.ts".to_string(),
"folder".to_string(),
"folder2/inner_folder".to_string(),
]),
disable_paths: vec!["folder/other.ts".to_string()],
..Default::default()
Expand Down Expand Up @@ -4101,6 +4104,10 @@ mod tests {
temp_dir.url().join("root1/folder/mod.ts").unwrap(),
temp_dir.url().join("root2/folder/main.ts").unwrap(),
temp_dir.url().join("root2/root2.1/main.ts").unwrap(),
temp_dir
.url()
.join("root2/folder2/inner_folder/main.ts")
.unwrap(),
])
);
}
Expand Down

0 comments on commit b5e4a30

Please sign in to comment.