aboutsummaryrefslogtreecommitdiff
path: root/src/platform/unix_common.rs
diff options
context:
space:
mode:
authorakbash <akbash@herdr.dev>2026-08-20 02:29:43 +0300
committerGitHub <noreply@github.com>2026-08-20 02:29:43 +0300
commit7d35ebe7c4d8eec960b30216829e7247d628f423 (patch)
tree316bd32afbcd0ff0025e0e6bc970cd137c0618c4 /src/platform/unix_common.rs
parent1b56601630c8de3825f18b37cfb4988ba87127f9 (diff)
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 <ogulcancelik@gmail.com>
Diffstat (limited to 'src/platform/unix_common.rs')
-rw-r--r--src/platform/unix_common.rs18
1 files changed, 18 insertions, 0 deletions
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);