Compare commits

...
Author SHA1 Message Date
l0ng-ai b3876c5640 test(heap): wait for the background cleanup in the stuck-capture shutdown test 2026-11-18 16:14:01 +08:00
Bin d72363b6ba fix(lsp): include workspace folder in ESLint configuration (#4145)
vscode-eslint resolves workingDirectory {mode: auto} from settings.workspaceFolder; without it the server falls back to the linted file's directory, so resolvers configured relative to the project (eslint-import-resolver-alias './src') looked under src/src and reported import/no-unresolved. The full workspace/configuration answer for eslint now carries the server root as workspaceFolder, as VS Code's client does. Other servers' answers are unchanged.

Closes #4143

Co-authored-by: ffgenius <[email protected]>
2026-11-18 16:11:18 +08:00
l0ng-ai 4ab4e0b44f fix(ci): use a Windows-absolute devshell path in the project environment test (#4149)
The project environment test's PATH entry /nix/store/x-devshell/bin has no drive letter on Windows, so the tool search path, which keeps absolute entries only, dropped it and the test failed there. The test uses C:\nix\store\x-devshell\bin on Windows.
2026-11-18 15:11:25 +08:00
4 changed files with 47 additions and 3 deletions

No files matched your search

+5 -3
View File
@@ -1062,11 +1062,13 @@ mod tests {
#[test]
fn a_child_inside_a_project_gets_its_environment() {
let root = std::path::Path::new("/openidea-test-process/project");
// Absolute on the platform: the search path drops relative entries.
let devshell = if cfg!(windows) { r"C:\nix\store\x-devshell\bin" } else { "/nix/store/x-devshell/bin" };
crate::project_env::set(
root,
vec![
("OPENIDEA_PROJECT_VAR".into(), Some("devshell".into())),
("PATH".into(), Some("/nix/store/x-devshell/bin".into())),
("PATH".into(), Some(devshell.into())),
("OPENIDEA_PROJECT_UNSET".into(), None),
],
);
@@ -1075,7 +1077,7 @@ mod tests {
let mut inside = Command::new("true");
inside.current_dir(root.join("src")).env("OPENIDEA_PROJECT_VAR", "call site");
host_env(&mut inside);
assert_eq!(get(&inside, "PATH"), Some(Some("/nix/store/x-devshell/bin".into())));
assert_eq!(get(&inside, "PATH"), Some(Some(devshell.into())));
assert_eq!(get(&inside, "OPENIDEA_PROJECT_UNSET"), Some(None));
assert_eq!(get(&inside, "OPENIDEA_PROJECT_VAR"), Some(Some("call site".into())), "the call site's value wins");
@@ -1093,7 +1095,7 @@ mod tests {
assert_eq!(host_var_os_in(root, "OPENIDEA_PROJECT_VAR"), Some("devshell".into()));
assert_eq!(host_var_os("OPENIDEA_PROJECT_VAR"), None);
let search = crate::tool_path::search_path_in(root);
assert_eq!(std::env::split_paths(&search).next(), Some("/nix/store/x-devshell/bin".into()));
assert_eq!(std::env::split_paths(&search).next(), Some(devshell.into()));
crate::project_env::remove(root);
assert!(host_vars_in(root).all(|(k, _)| k != "OPENIDEA_PROJECT_VAR"));
}
+5
View File
@@ -311,6 +311,11 @@ async fn shutdown_does_not_wait_forever_for_a_stuck_capture() {
shutdown_within(&f.host, std::time::Duration::from_millis(200)).await;
assert!(started.elapsed() < std::time::Duration::from_secs(5));
assert!(cancel.is_cancelled());
// The cleanup is only waited for briefly and finishes in the background on a busy machine.
let deadline = std::time::Instant::now() + std::time::Duration::from_secs(10);
while stuck_dir.exists() && std::time::Instant::now() < deadline {
tokio::time::sleep(std::time::Duration::from_millis(20)).await;
}
assert!(!stuck_dir.exists(), "its directory is removed once the wait is over");
}
+8
View File
@@ -435,6 +435,14 @@ impl ClientHandler {
.find_map(|base| section.split('.').try_fold(base, |v, key| v.get(key)))
.cloned()
.unwrap_or(Value::Null),
None if self.server.name == "eslint" => {
let mut settings = options.clone();
settings["workspaceFolder"] = json!({
"uri": crate::uri::path_to_uri(&self.server.root),
"name": self.server.root.file_name().map_or_else(|| "root".into(), |name| name.to_string_lossy().into_owned()),
});
settings
}
None => options.clone(),
})
.collect(),
+29
View File
@@ -2568,6 +2568,35 @@ async fn configuration_answer_resyncs_open_documents_of_opted_in_servers() {
assert_eq!(s.launches.load(Ordering::SeqCst), 1);
}
#[tokio::test(flavor = "multi_thread")]
async fn eslint_configuration_includes_workspace_folder() {
let h = harness_configured("mock", "mk", &[("eslint", incremental_caps()), ("mock", incremental_caps())], |cfg| {
if cfg.name == "eslint" {
cfg.settings = Some(json!({ "workingDirectory": { "mode": "auto" } }));
}
});
h.open("a.mk", "x");
h.wait_status("eslint", ServerStatus::Ready).await;
h.wait_status("mock", ServerStatus::Ready).await;
let items = json!({ "items": [{ "section": "" }] });
let eslint: Value =
h.launcher.state("eslint").peer().request("workspace/configuration", items.clone(), None).await.unwrap();
assert_eq!(
eslint,
json!([{
"flag": true,
"nested": { "deep": 1 },
"workingDirectory": { "mode": "auto" },
"workspaceFolder": {
"uri": uri_of(&h.root),
"name": h.root.file_name().unwrap().to_string_lossy(),
},
}])
);
let other: Value = h.launcher.state("mock").peer().request("workspace/configuration", items, None).await.unwrap();
assert_eq!(other, json!([{ "flag": true, "nested": { "deep": 1 } }]));
}
#[tokio::test(flavor = "multi_thread")]
async fn settings_changes_reach_servers_without_restarts() {
let h = harness(&[("mock", incremental_caps()), ("extra", incremental_caps())]);