From 7d35ebe7c4d8eec960b30216829e7247d628f423 Mon Sep 17 00:00:00 2001 From: akbash Date: Thu, 20 Aug 2026 02:29:43 +0300 Subject: fix: synchronize plugin pane pwd (#2985) * fix: synchronize plugin pane pwd refs #2984 * refactor: isolate plugin pwd platform policy refs #2984 * docs: fix changelog conflict resolution --------- Co-authored-by: akbash-bot <300245827+akbash-bot@users.noreply.github.com> Co-authored-by: Can Celik --- src/platform/unix_common.rs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'src/platform/unix_common.rs') 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,10 +228,28 @@ fn datetime_from_tm(value: &libc::tm) -> Option { 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(); -- cgit v1.2.3