From 95edcb880af8ec2422dba0718a928bbc1d587bbc Mon Sep 17 00:00:00 2001 From: l0ng-ai <24760907+l0ng-ai@users.noreply.github.com> Date: Wed, 4 Nov 2026 12:15:26 +0800 Subject: [PATCH] fix(maven): keep edited nested test launchers when refreshing defaults --- crates/ide-sdk/src/apply.rs | 10 ++++------ crates/ide-sdk/src/tests.rs | 11 +++++++++++ 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/crates/ide-sdk/src/apply.rs b/crates/ide-sdk/src/apply.rs index 088d2df4..a496a433 100644 --- a/crates/ide-sdk/src/apply.rs +++ b/crates/ide-sdk/src/apply.rs @@ -252,12 +252,10 @@ pub fn prepare_maven_run(config: &mut RunConfig, root: &Path, s: &Settings) { let id = id.strip_prefix("workspace:").and_then(|id| id.split_once(':')).map_or(id, |(_, id)| id); let source = ide_run::detect(root) .into_iter() - .filter(|base| { - base.kind == "maven" - && (id == base.id || id.starts_with(&format!("{}:", base.id))) - && !saved.iter().any(|user| user.id == base.id) - }) - .max_by_key(|base| base.id.len()); + .chain(saved.iter().cloned()) + .filter(|base| base.kind == "maven" && (id == base.id || id.starts_with(&format!("{}:", base.id)))) + .max_by_key(|base| base.id.len()) + .filter(|base| !saved.iter().any(|user| user.id == base.id)); if let Some(base) = source.filter(|_| config.extras.params.is_empty()) { if let Some(prefix) = maven_settings_prefixes(&config.args) .into_iter() diff --git a/crates/ide-sdk/src/tests.rs b/crates/ide-sdk/src/tests.rs index 2dfc83b1..4a61ad1d 100644 --- a/crates/ide-sdk/src/tests.rs +++ b/crates/ide-sdk/src/tests.rs @@ -357,6 +357,17 @@ fn maven_launch_refreshes_legacy_defaults_but_keeps_user_overrides() { prepare_maven_run(&mut explicit, tmp.path(), &s); assert_eq!(explicit.command, "/custom/mvn"); assert_eq!(explicit.args, ["-s", "own-settings.xml", "-Dmaven.repo.local=own-repo", "test"]); + + std::fs::create_dir(tmp.path().join("child")).unwrap(); + std::fs::write(tmp.path().join("child/pom.xml"), "").unwrap(); + let mut nested = explicit.clone(); + nested.id = "maven:test:child".into(); + nested.detected = false; + ide_run::save_user_configs(tmp.path(), &[nested]).unwrap(); + explicit.id = "context:maven:test:child:src/test/java/ExampleTest.java".into(); + prepare_maven_run(&mut explicit, tmp.path(), &s); + assert_eq!(explicit.command, "/custom/mvn", "an edited child must not fall back to the parent's defaults"); + assert_eq!(explicit.args, ["-s", "own-settings.xml", "-Dmaven.repo.local=own-repo", "test"]); } #[test]