diff --git a/kaku-gui/src/termwindow/resize.rs b/kaku-gui/src/termwindow/resize.rs index 4becdf90e..066242b59 100644 --- a/kaku-gui/src/termwindow/resize.rs +++ b/kaku-gui/src/termwindow/resize.rs @@ -555,6 +555,12 @@ impl super::TermWindow { tab.resize(size); } } + for tab in window.iter() { + for pos in tab.iter_panes_ignoring_zoom() { + let mut state = self.pane_state(pos.pane.pane_id()); + state.viewport = None; + } + } }; if live { self.pending_pty_flush_after_resize = true; diff --git a/term/src/screen.rs b/term/src/screen.rs index 2153436ab..b8d1a6709 100644 --- a/term/src/screen.rs +++ b/term/src/screen.rs @@ -224,10 +224,18 @@ impl Screen { // pre-prune blank lines that range from the cursor position to the end of the display; // this avoids growing the scrollback size when rapidly switching between normal and // maximized states. + // Limit pruning to lines beyond the visible viewport to avoid losing + // scrollback content during repeated resizes. let cursor_phys = self.phys_row(cursor.y); + let max_prune = self.lines.len().saturating_sub(self.physical_rows); + let mut pruned = 0; for _ in cursor_phys + 1..self.lines.len() { + if pruned >= max_prune { + break; + } if self.lines.back().map(Line::is_whitespace).unwrap_or(false) { self.lines.pop_back(); + pruned += 1; } }