T29: inside herdr the right column follows herdr's focused pane: herdr keeps its panes' OSC 7, so on macOS and Linux a session that finds herdr's client leading its pty's foreground reads the focused pane's folder from herdr's socket, found as herdr 0.9 finds it
CI / platforms (ubuntu-24.04) (push) Successful in 1m11s
CI / platforms (windows-latest) (push) Successful in 1m40s
CI / macos (push) Successful in 11m13s

This commit is contained in:
ZacharyZhang-NY committed 2026-10-16 02:58:38 -04:00
1 parent 6c610fdc6e
commit 3e30f95543
11 files changed
+606 -7

No files matched your search

+33 -3
View File
@@ -56,7 +56,7 @@ pub struct Pty {
pub term: Arc<FairMutex<Term<Listener>>>,
pub pid: u32,
notifier: Notifier,
#[cfg(all(test, unix))]
#[cfg(unix)]
master: std::fs::File,
}
@@ -111,7 +111,7 @@ pub fn spawn(
)
})?;
let pid = child_id(&raw)?;
#[cfg(all(test, unix))]
#[cfg(unix)]
let master = raw
.master()
.map_err(|error| anyhow::anyhow!("pty {pid}: no copy of the master: {error}"))?;
@@ -141,7 +141,7 @@ pub fn spawn(
term,
pid,
notifier,
#[cfg(all(test, unix))]
#[cfg(unix)]
master,
},
events,
@@ -184,6 +184,15 @@ impl Pty {
}
}
#[cfg(unix)]
impl Pty {
/// The process group the program runs in the foreground.
pub fn foreground(&self) -> std::io::Result<i32> {
let group = rustix_openpty::rustix::termios::tcgetpgrp(&self.master)?;
Ok(group.as_raw_nonzero().get())
}
}
#[cfg(all(test, unix))]
impl Pty {
/// Whether the program reads raw keys, canonical mode off.
@@ -305,6 +314,27 @@ mod tests {
assert_eq!(ran.text, "x");
}
#[test]
fn the_foreground_is_the_program_s_own_group() {
let launch = Launch {
program: Some(("/bin/sh".into(), vec!["-c".into(), "exec sleep 30".into()])),
cwd: std::env::temp_dir(),
env: Vec::new(),
reports: false,
};
let (pty, _events) =
spawn(&launch, (20, 4), (8, 16), config(&Settings::default())).expect("sh starts");
let deadline = std::time::Instant::now() + std::time::Duration::from_secs(5);
while pty.foreground().ok() != Some(pty.pid as i32) {
assert!(
std::time::Instant::now() < deadline,
"{:?}",
pty.foreground()
);
std::thread::sleep(std::time::Duration::from_millis(10));
}
}
#[test]
fn a_size_past_the_kernel_is_one_size_for_grid_and_program() {
let ran = run("stty size", (9000, 8));