diff --git a/src/pane.rs b/src/pane.rs index 59dee7ef..ad9e1f92 100644 --- a/src/pane.rs +++ b/src/pane.rs @@ -2693,7 +2693,6 @@ impl PaneRuntime { .lock() .ok() .and_then(|reported_cwd| reported_cwd.clone()) - .and_then(usable_reported_cwd) { return Some(cwd); } @@ -2826,6 +2825,32 @@ impl PaneRuntime { mod tests { use super::*; + #[tokio::test] + async fn cwd_returns_accepted_report_without_rechecking_filesystem() { + let stamp = std::time::SystemTime::now() + .duration_since(std::time::UNIX_EPOCH) + .expect("clock should be after unix epoch") + .as_nanos(); + let cwd = std::env::temp_dir().join(format!( + "herdr-reported-cwd-cache-{}-{stamp}", + std::process::id() + )); + std::fs::create_dir(&cwd).expect("create reported cwd"); + + let (runtime, _rx) = PaneRuntime::test_with_channel(80, 24); + let (events, _event_rx) = mpsc::channel(1); + publish_reported_cwd(runtime.pane_id, cwd.clone(), &runtime.reported_cwd, &events); + assert_eq!( + runtime.reported_cwd.lock().unwrap().as_ref(), + Some(&cwd), + "test setup must pass cache admission" + ); + + std::fs::remove_dir(&cwd).expect("remove reported cwd after admission"); + + assert_eq!(runtime.cwd(), Some(cwd)); + } + #[cfg(unix)] #[tokio::test] async fn follow_cwd_falls_back_to_reported_pane_cwd_without_foreground_group() {