From a51902ede97afd84b469f838f25ab79287bd375d Mon Sep 17 00:00:00 2001 From: Ogulcan Celik Date: Tue, 7 Apr 2026 00:04:32 +0300 Subject: fix: use byte-based pane scrollback limit --- src/pane.rs | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) (limited to 'src/pane.rs') diff --git a/src/pane.rs b/src/pane.rs index a170d295..e2afccdc 100644 --- a/src/pane.rs +++ b/src/pane.rs @@ -1344,6 +1344,7 @@ impl PaneRuntime { rows: u16, cols: u16, cwd: std::path::PathBuf, + scrollback_limit_bytes: usize, _host_terminal_theme: crate::terminal_theme::TerminalTheme, events: mpsc::Sender, render_notify: Arc, @@ -1362,7 +1363,12 @@ impl PaneRuntime { // --- Writer channel --- let (input_tx, mut input_rx) = mpsc::channel::(32); - let terminal = crate::ghostty::Terminal::new(cols, rows, 10000) + info!( + pane = pane_id.raw(), + rows, cols, scrollback_limit_bytes, "spawning pane terminal" + ); + + let terminal = crate::ghostty::Terminal::new(cols, rows, scrollback_limit_bytes) .map_err(|e| std::io::Error::other(e.to_string()))?; let pane_terminal = GhosttyPaneTerminal::new(terminal, input_tx.clone())?; pane_terminal.apply_host_terminal_theme(_host_terminal_theme); @@ -1807,6 +1813,12 @@ impl PaneRuntime { mod tests { use super::*; + fn write_numbered_lines(terminal: &mut crate::ghostty::Terminal, count: usize) { + for i in 0..count { + terminal.write(format!("{i:06}\r\n").as_bytes()); + } + } + #[test] fn ghostty_keyboard_protocol_tracks_live_terminal_flags() { let (tx, _rx) = mpsc::channel(4); @@ -1933,6 +1945,24 @@ mod tests { ); } + #[test] + fn pane_scrollback_controls_reach_top_without_ui_interference() { + let (tx, _rx) = mpsc::channel(4); + let mut terminal = crate::ghostty::Terminal::new(80, 3, 100).unwrap(); + write_numbered_lines(&mut terminal, 1000); + let pane = GhosttyPaneTerminal::new(terminal, tx).unwrap(); + + let before = pane.scroll_metrics().expect("scroll metrics before scroll"); + assert!(before.max_offset_from_bottom > 0); + assert_eq!(before.offset_from_bottom, 0); + + pane.set_scroll_offset_from_bottom(before.max_offset_from_bottom); + + let after = pane.scroll_metrics().expect("scroll metrics after scroll"); + assert_eq!(after.offset_from_bottom, after.max_offset_from_bottom); + assert!(pane.visible_text().contains("000000")); + } + #[test] fn synchronized_output_suppresses_intermediate_render_requests_until_batch_ends() { let (tx, _rx) = mpsc::channel(4); -- cgit v1.2.3