Use native quoting for VS Code fallback
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
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:
+33
-10
@@ -2727,17 +2727,23 @@ fn launch_vscode_remote(alias: &str, remote_path: Option<&str>) -> Result<()> {
|
|||||||
}
|
}
|
||||||
if saw_not_found {
|
if saw_not_found {
|
||||||
println!(
|
println!(
|
||||||
"Run: code --remote {}{}",
|
"Run: {}",
|
||||||
shell_word(&remote),
|
vscode_fallback_command(std::env::consts::OS, &remote, remote_path)
|
||||||
remote_path
|
|
||||||
.map(|path| format!(" {}", shell_word(path)))
|
|
||||||
.unwrap_or_default()
|
|
||||||
);
|
);
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
Err(anyhow!("no VS Code command candidates configured"))
|
Err(anyhow!("no VS Code command candidates configured"))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn vscode_fallback_command(os: &str, remote: &str, remote_path: Option<&str>) -> String {
|
||||||
|
let mut command = format!("code --remote {}", ssh_config_word_for_os(os, remote));
|
||||||
|
if let Some(path) = remote_path {
|
||||||
|
command.push(' ');
|
||||||
|
command.push_str(&ssh_config_word_for_os(os, path));
|
||||||
|
}
|
||||||
|
command
|
||||||
|
}
|
||||||
|
|
||||||
fn vscode_command_candidates(os: &str) -> &'static [&'static str] {
|
fn vscode_command_candidates(os: &str) -> &'static [&'static str] {
|
||||||
if os == "windows" {
|
if os == "windows" {
|
||||||
&["code.cmd", "code.exe", "code"]
|
&["code.cmd", "code.exe", "code"]
|
||||||
@@ -10633,11 +10639,12 @@ mod tests {
|
|||||||
summarize_trace_file_with_mode, terminal_private_mode_transition, toml_bare_key_or_quoted,
|
summarize_trace_file_with_mode, terminal_private_mode_transition, toml_bare_key_or_quoted,
|
||||||
top_trace_events, trace_report_warnings, unix_update_script,
|
top_trace_events, trace_report_warnings, unix_update_script,
|
||||||
update_binary_version_for_installer, update_installer_url, update_version_status,
|
update_binary_version_for_installer, update_installer_url, update_version_status,
|
||||||
upsert_managed_block, valid_forward_host, vscode_command_candidates, vscode_safe_alias,
|
upsert_managed_block, valid_forward_host, vscode_command_candidates,
|
||||||
wake_repaint_retry_deadline, windows_command_word, windows_deferred_update_script,
|
vscode_fallback_command, vscode_safe_alias, wake_repaint_retry_deadline,
|
||||||
windows_effective_url_script, windows_mode_from_readonly,
|
windows_command_word, windows_deferred_update_script, windows_effective_url_script,
|
||||||
windows_powershell_command_candidates, windows_readonly_from_mode, windows_update_script,
|
windows_mode_from_readonly, windows_powershell_command_candidates,
|
||||||
windows_url_reachable_script, windows_vt_output_mode,
|
windows_readonly_from_mode, windows_update_script, windows_url_reachable_script,
|
||||||
|
windows_vt_output_mode,
|
||||||
};
|
};
|
||||||
use dosh::config::{ClientConfig, CommandExtension, HostConfig};
|
use dosh::config::{ClientConfig, CommandExtension, HostConfig};
|
||||||
use dosh::native::EnvVar;
|
use dosh::native::EnvVar;
|
||||||
@@ -10700,6 +10707,22 @@ mod tests {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn vscode_fallback_command_quotes_for_each_platform() {
|
||||||
|
assert_eq!(
|
||||||
|
vscode_fallback_command("macos", "ssh-remote+dosh-prod", Some("/srv/my app")),
|
||||||
|
"code --remote 'ssh-remote+dosh-prod' '/srv/my app'"
|
||||||
|
);
|
||||||
|
assert_eq!(
|
||||||
|
vscode_fallback_command(
|
||||||
|
"windows",
|
||||||
|
"ssh-remote+dosh-prod",
|
||||||
|
Some(r#"C:\Users\alice\My App"#)
|
||||||
|
),
|
||||||
|
r#"code --remote "ssh-remote+dosh-prod" "C:\Users\alice\My App""#
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn forward_agent_endpoint_disabled_is_none() {
|
fn forward_agent_endpoint_disabled_is_none() {
|
||||||
assert_eq!(resolve_forward_agent_endpoint(false).unwrap(), None);
|
assert_eq!(resolve_forward_agent_endpoint(false).unwrap(), None);
|
||||||
|
|||||||
Reference in New Issue
Block a user