diff options
Diffstat (limited to 'src/platform')
| -rw-r--r-- | src/platform/fallback.rs | 10 | ||||
| -rw-r--r-- | src/platform/linux.rs | 3 | ||||
| -rw-r--r-- | src/platform/macos.rs | 3 | ||||
| -rw-r--r-- | src/platform/unix_common.rs | 18 | ||||
| -rw-r--r-- | src/platform/windows.rs | 6 |
5 files changed, 38 insertions, 2 deletions
diff --git a/src/platform/fallback.rs b/src/platform/fallback.rs index cdfbc157..64e5467b 100644 --- a/src/platform/fallback.rs +++ b/src/platform/fallback.rs @@ -3,6 +3,16 @@ use std::process::Command; use super::{ClipboardImage, ForegroundJob, Signal}; +#[cfg(unix)] +pub(crate) use super::unix_common::set_default_plugin_pane_pwd; + +#[cfg(not(unix))] +pub(crate) fn set_default_plugin_pane_pwd( + _env: &mut Vec<(String, String)>, + _cwd: &std::path::Path, +) { +} + pub(crate) fn remote_ssh_config_paths() -> super::RemoteSshConfigPaths { super::RemoteSshConfigPaths { user_config: std::env::var_os("HOME") diff --git a/src/platform/linux.rs b/src/platform/linux.rs index b5c33259..fde57e57 100644 --- a/src/platform/linux.rs +++ b/src/platform/linux.rs @@ -16,7 +16,8 @@ pub(crate) use super::unix_common::{ configure_status_command, create_remote_private_dir, create_remote_ssh_config_dir, create_remote_ssh_config_file, hostname, local_datetime, remote_bridge_endpoint_path, remote_private_temp_base, remote_reattach_argument, remote_reattach_program, - remote_ssh_config_paths, status_commands_supported, StatusCommandGuard, + remote_ssh_config_paths, set_default_plugin_pane_pwd, status_commands_supported, + StatusCommandGuard, }; const WSL_MARKER_ENV_VARS: &[&str] = &["WSL_DISTRO_NAME", "WSL_INTEROP"]; diff --git a/src/platform/macos.rs b/src/platform/macos.rs index 00fd2452..948468ac 100644 --- a/src/platform/macos.rs +++ b/src/platform/macos.rs @@ -16,7 +16,8 @@ pub(crate) use super::unix_common::{ configure_status_command, create_remote_private_dir, create_remote_ssh_config_dir, create_remote_ssh_config_file, hostname, local_datetime, remote_bridge_endpoint_path, remote_private_temp_base, remote_reattach_argument, remote_reattach_program, - remote_ssh_config_paths, status_commands_supported, StatusCommandGuard, + remote_ssh_config_paths, set_default_plugin_pane_pwd, status_commands_supported, + StatusCommandGuard, }; const PROC_PGRP_ONLY: u32 = 2; diff --git a/src/platform/unix_common.rs b/src/platform/unix_common.rs index b997049f..ce5bba00 100644 --- a/src/platform/unix_common.rs +++ b/src/platform/unix_common.rs @@ -228,11 +228,29 @@ fn datetime_from_tm(value: &libc::tm) -> Option<time::PrimitiveDateTime> { Some(time::PrimitiveDateTime::new(date, time)) } +pub(crate) fn set_default_plugin_pane_pwd(env: &mut Vec<(String, String)>, cwd: &std::path::Path) { + if !env.iter().any(|(key, _)| key == "PWD") { + env.push(("PWD".to_string(), cwd.display().to_string())); + } +} + #[cfg(test)] mod tests { use super::*; #[test] + fn plugin_pane_pwd_defaults_to_cwd_without_overriding_explicit_env() { + let cwd = Path::new("/plugin-cwd"); + let mut derived = vec![("OTHER".to_string(), "value".to_string())]; + set_default_plugin_pane_pwd(&mut derived, cwd); + assert!(derived.contains(&("PWD".to_string(), "/plugin-cwd".to_string()))); + + let mut explicit = vec![("PWD".to_string(), "/caller-pwd".to_string())]; + set_default_plugin_pane_pwd(&mut explicit, cwd); + assert_eq!(explicit, [("PWD".to_string(), "/caller-pwd".to_string())]); + } + + #[test] fn remote_ssh_config_dir_rejects_overlong_control_socket_name() { let err = create_remote_ssh_config_dir(&"x".repeat(200)).unwrap_err(); assert_eq!(err.kind(), std::io::ErrorKind::InvalidInput); diff --git a/src/platform/windows.rs b/src/platform/windows.rs index 7aee384e..5d5b0141 100644 --- a/src/platform/windows.rs +++ b/src/platform/windows.rs @@ -15,6 +15,12 @@ use std::{ mod clipboard_image; +pub(crate) fn set_default_plugin_pane_pwd( + _env: &mut Vec<(String, String)>, + _cwd: &std::path::Path, +) { +} + use windows_sys::{ Wdk::System::Threading::{NtQueryInformationProcess, ProcessBasicInformation}, Win32::{ |
