fix(maven): keep edited nested test launchers when refreshing defaults

This commit is contained in:
l0ng-ai
2026-11-04 12:15:26 +08:00
parent 4824e0ed8a
commit 95edcb880a
2 changed files with 15 additions and 6 deletions
+4 -6
View File
@@ -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()
+11
View File
@@ -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"), "<project/>").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]