Try Windows VS Code command shims
ci / test (push) Canceled after 0s
ci / fuzz-smoke (push) Canceled after 0s
ci / macos-client (macos-aarch64, macos-14) (push) Canceled after 0s
ci / macos-client (macos-x86_64, macos-13) (push) Canceled after 0s
ci / windows-client (push) Canceled after 0s
ci / package-release (linux-x86_64, ubuntu-latest, , , ) (push) Canceled after 0s
ci / package-release (macos-aarch64, macos-14, , , ) (push) Canceled after 0s
ci / package-release (macos-x86_64, macos-13, , , ) (push) Canceled after 0s
ci / package-release (windows-aarch64, windows-latest, aarch64, windows, aarch64-pc-windows-msvc) (push) Canceled after 0s
ci / package-release (windows-x86_64, windows-latest, , , ) (push) Canceled after 0s
ci / remote-bench (push) Canceled after 0s
ci / publish-gitea-release (push) Canceled after 0s

This commit is contained in:
DuProcess
2026-07-16 20:36:03 -04:00
parent b84ec4eb3f
commit 9969971605
+47 -21
View File
@@ -2676,25 +2676,40 @@ fn vscode_safe_alias(value: &str) -> String {
fn launch_vscode_remote(alias: &str, remote_path: Option<&str>) -> Result<()> {
let remote = format!("ssh-remote+{alias}");
let mut command = Command::new("code");
command.arg("--remote").arg(&remote);
if let Some(path) = remote_path {
command.arg(path);
}
match command.status() {
Ok(status) if status.success() => Ok(()),
Ok(status) => Err(anyhow!("code exited with status {status}")),
Err(err) if err.kind() == std::io::ErrorKind::NotFound => {
println!(
"Run: code --remote {}{}",
shell_word(&remote),
remote_path
.map(|path| format!(" {}", shell_word(path)))
.unwrap_or_default()
);
Ok(())
let mut saw_not_found = false;
for candidate in vscode_command_candidates(std::env::consts::OS) {
let mut command = Command::new(candidate);
command.arg("--remote").arg(&remote);
if let Some(path) = remote_path {
command.arg(path);
}
Err(err) => Err(err).context("launch VS Code"),
match command.status() {
Ok(status) if status.success() => return Ok(()),
Ok(status) => return Err(anyhow!("{candidate} exited with status {status}")),
Err(err) if err.kind() == std::io::ErrorKind::NotFound => saw_not_found = true,
Err(err) => {
return Err(err).with_context(|| format!("launch VS Code with {candidate}"));
}
}
}
if saw_not_found {
println!(
"Run: code --remote {}{}",
shell_word(&remote),
remote_path
.map(|path| format!(" {}", shell_word(path)))
.unwrap_or_default()
);
return Ok(());
}
Err(anyhow!("no VS Code command candidates configured"))
}
fn vscode_command_candidates(os: &str) -> &'static [&'static str] {
if os == "windows" {
&["code.cmd", "code.exe", "code"]
} else {
&["code"]
}
}
@@ -10351,9 +10366,10 @@ mod tests {
terminal_private_mode_transition, toml_bare_key_or_quoted, top_trace_events,
trace_report_warnings, unix_update_script, update_binary_version_for_installer,
update_installer_url, update_version_status, upsert_managed_block, valid_forward_host,
vscode_safe_alias, wake_repaint_retry_deadline, windows_command_word,
windows_deferred_update_script, windows_effective_url_script, windows_mode_from_readonly,
windows_readonly_from_mode, windows_update_script, windows_url_reachable_script,
vscode_command_candidates, vscode_safe_alias, wake_repaint_retry_deadline,
windows_command_word, windows_deferred_update_script, windows_effective_url_script,
windows_mode_from_readonly, windows_readonly_from_mode, windows_update_script,
windows_url_reachable_script,
};
use dosh::config::{ClientConfig, CommandExtension, HostConfig};
use dosh::native::EnvVar;
@@ -10406,6 +10422,16 @@ mod tests {
assert_eq!(vscode_safe_alias(":///"), "host");
}
#[test]
fn vscode_command_candidates_are_platform_native() {
assert_eq!(vscode_command_candidates("macos"), &["code"]);
assert_eq!(vscode_command_candidates("linux"), &["code"]);
assert_eq!(
vscode_command_candidates("windows"),
&["code.cmd", "code.exe", "code"]
);
}
#[test]
fn forward_agent_endpoint_disabled_is_none() {
assert_eq!(resolve_forward_agent_endpoint(false).unwrap(), None);