From 169a4fd90c20a00aec77d684ecec98b9f0f996cc Mon Sep 17 00:00:00 2001 From: Ogulcan Celik Date: Fri, 24 Jul 2026 02:39:42 +0300 Subject: fix: answer XTWINOPS size queries in panes refs #835 --- src/pane/terminal.rs | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) (limited to 'src/pane') diff --git a/src/pane/terminal.rs b/src/pane/terminal.rs index 23dcffff..81c57ef9 100644 --- a/src/pane/terminal.rs +++ b/src/pane/terminal.rs @@ -4483,6 +4483,60 @@ mod tests { assert!(pane.recent_text(3).trim().is_empty()); } + #[test] + fn process_pty_bytes_answers_xtwinops_size_queries() { + let (tx, _rx) = mpsc::channel(4); + let terminal = crate::ghostty::Terminal::new(80, 24, 0).unwrap(); + let pane = GhosttyPaneTerminal::new(terminal, tx.clone()).unwrap(); + let pane_id = PaneId::from_raw(1); + pane.resize(24, 80, 9, 18); + + let result = pane.process_pty_bytes(pane_id, 0, b"\x1b[14t\x1b[16t\x1b[18t", &tx); + + assert_eq!( + result.terminal_responses, + vec![ + Bytes::from_static(b"\x1b[4;432;720t"), + Bytes::from_static(b"\x1b[6;18;9t"), + Bytes::from_static(b"\x1b[8;24;80t"), + ] + ); + } + + #[test] + fn xtwinops_size_queries_follow_successful_resize() { + let (tx, _rx) = mpsc::channel(4); + let terminal = crate::ghostty::Terminal::new(80, 24, 0).unwrap(); + let pane = GhosttyPaneTerminal::new(terminal, tx.clone()).unwrap(); + let pane_id = PaneId::from_raw(1); + pane.resize(24, 80, 9, 18); + pane.resize(30, 100, 10, 20); + + let result = pane.process_pty_bytes(pane_id, 0, b"\x1b[14t\x1b[16t\x1b[18t", &tx); + + assert_eq!( + result.terminal_responses, + vec![ + Bytes::from_static(b"\x1b[4;600;1000t"), + Bytes::from_static(b"\x1b[6;20;10t"), + Bytes::from_static(b"\x1b[8;30;100t"), + ] + ); + } + + #[test] + fn xtwinops_size_queries_stay_silent_without_pixel_geometry() { + let (tx, _rx) = mpsc::channel(4); + let terminal = crate::ghostty::Terminal::new(80, 24, 0).unwrap(); + let pane = GhosttyPaneTerminal::new(terminal, tx.clone()).unwrap(); + let pane_id = PaneId::from_raw(1); + for (cell_width_px, cell_height_px) in [(0, 0), (0, 18), (9, 0)] { + pane.resize(24, 80, cell_width_px, cell_height_px); + let result = pane.process_pty_bytes(pane_id, 0, b"\x1b[14t\x1b[16t\x1b[18t", &tx); + assert!(result.terminal_responses.is_empty()); + } + } + #[test] fn resize_returns_in_band_size_report_response() { let (tx, _rx) = mpsc::channel(4); -- cgit v1.2.3