diff options
| author | Ogulcan Celik <ogulcancelik@gmail.com> | 2026-04-07 00:04:32 +0300 |
|---|---|---|
| committer | Ogulcan Celik <ogulcancelik@gmail.com> | 2026-04-07 00:04:32 +0300 |
| commit | a51902ede97afd84b469f838f25ab79287bd375d (patch) | |
| tree | 986cf68f33370450eae9152ac3c2015aeebe5882 /src/pane.rs | |
| parent | 6ccf156a3dd23f419c03892ddc1136e72957f66a (diff) | |
fix: use byte-based pane scrollback limit
Diffstat (limited to 'src/pane.rs')
| -rw-r--r-- | src/pane.rs | 32 |
1 files changed, 31 insertions, 1 deletions
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<AppEvent>, render_notify: Arc<Notify>, @@ -1362,7 +1363,12 @@ impl PaneRuntime { // --- Writer channel --- let (input_tx, mut input_rx) = mpsc::channel::<Bytes>(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); @@ -1934,6 +1946,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); let terminal = crate::ghostty::Terminal::new(80, 24, 0).unwrap(); |
