fix(sdk): distinguish mapped roots from external launcher links

Цей коміт міститься в:
l0ng-ai committed 2026-11-04 11:43:56 +08:00
1 джерело ca6adc65de
коміт 7e48471b76
5 files changed
+29 -10

No files matched your search

+1 -1
Переглянути файл
@@ -75,7 +75,7 @@ pub fn save_configs(
let configs: Vec<RunConfig> = configs
.iter()
.map(|c| match c.kind.as_str() {
"gradle" => c.clone(),
"gradle" | "maven" => c.clone(),
_ => ide_sdk::apply::without_derived(c, &project.root, &settings),
})
.collect();
+14 -7
Переглянути файл
@@ -241,13 +241,20 @@ pub fn prepare_maven_run(config: &mut RunConfig, root: &Path, s: &Settings) {
}
} else if config.detected || config.id.starts_with("context:") {
let saved = ide_run::load_user_configs(root).unwrap_or_default();
let source = ide_run::detect(root).into_iter().find(|base| {
base.kind == "maven"
&& (config.id == base.id
|| config.id.starts_with(&format!("context:{}:", base.id))
|| config.id.starts_with(&format!("context:target:context:{}:", base.id)))
&& !saved.iter().any(|user| user.id == base.id)
});
let id = config
.id
.strip_prefix("context:target:context:")
.or_else(|| config.id.strip_prefix("context:"))
.unwrap_or(&config.id);
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());
if let Some(base) = source.filter(|_| config.extras.params.is_empty()) {
if let Some(prefix) = maven_settings_prefixes(&config.args)
.into_iter()
+5
Переглянути файл
@@ -699,6 +699,11 @@ mod maven_path_tests {
assert_eq!(launch_path(&launcher).unwrap(), launcher);
assert_eq!(maven_home(&home), Some(home.clone()));
assert_eq!(maven_version(&home).as_deref(), Some("3.9.16"));
let jdk = drive.root.join("jdk");
std::fs::create_dir_all(jdk.join("bin")).unwrap();
std::fs::write(jdk.join("bin/java.exe"), "").unwrap();
std::fs::write(jdk.join("release"), "JAVA_VERSION=\"17.0.9\"\n").unwrap();
assert_eq!(crate::java::jdk_at(&jdk).unwrap().home, jdk);
}
#[test]
+7 -2
Переглянути файл
@@ -83,7 +83,7 @@ pub(crate) fn exe(name: &str) -> String {
}
/// `path` with symlinks resolved (Homebrew's `bin/mvn` → its Cellar), except that a Windows
/// drive letter is kept: on a mapped network drive or a `subst` drive canonicalizing gives
/// mapped drive letter is kept when the target stays inside that drive: canonicalizing gives
/// `\\?\UNC\server\share\…` or another drive, and cmd.exe can't start a script from a
/// `\\?\` path (`mvn.cmd`, or `mvn.cmd` with such a `JAVA_HOME`), nor is it the path the user knows.
pub(crate) fn launch_path(path: &Path) -> std::io::Result<PathBuf> {
@@ -101,7 +101,12 @@ pub(crate) fn launch_path(path: &Path) -> std::io::Result<PathBuf> {
if let Some(d) = drive(path)
&& drive(&real) != Some(d)
{
return std::path::absolute(path);
let root = PathBuf::from(format!("{}:\\", char::from(d)));
if let Ok(mapped) = dunce::canonicalize(&root)
&& let Ok(relative) = real.strip_prefix(mapped)
{
return Ok(root.join(relative));
}
}
}
Ok(real)
+2
Переглянути файл
@@ -305,6 +305,8 @@ fn maven_launch_refreshes_legacy_defaults_but_keeps_user_overrides() {
"maven:test",
"context:maven:test:src/test/java/ExampleTest.java",
"context:target:context:maven:test:src/test/java/ExampleTest.java:ExampleTest#example",
"workspace:abc:maven:test",
"context:target:context:workspace:abc:maven:test:src/test/java/ExampleTest.java:ExampleTest#example",
] {
let mut config = run(
"maven",