diff --git a/term/src/screen.rs b/term/src/screen.rs index 33d25cb6a..bc9d001e2 100644 --- a/term/src/screen.rs +++ b/term/src/screen.rs @@ -175,7 +175,7 @@ impl Screen { } } - let (cursor_x, cursor_y) = if self.allow_scrollback && physical_cols != self.physical_cols { + let (cursor_x, cursor_y) = if physical_cols != self.physical_cols { // Check to see if we need to rewrap lines that were // wrapped due to reaching the right hand side of the terminal. // For each one that we find, we need to join it with its @@ -183,7 +183,20 @@ impl Screen { // We only do this for the primary, and not for the alternate // screen (hence the check for allow_scrollback), to avoid // conflicting screen updates with full screen apps. - self.rewrap_lines(physical_cols, physical_rows, cursor.x, cursor_phys) + if self.allow_scrollback { + self.rewrap_lines(physical_cols, physical_rows, cursor.x, cursor_phys) + } else { + for line in &mut self.lines { + if physical_cols < self.physical_cols { + // Do a simple prune of the lines instead + line.resize(physical_cols); + } else { + // otherwise: invalidate them + line.set_dirty(); + } + } + (cursor.x, cursor_phys) + } } else { (cursor.x, cursor_phys) }; diff --git a/termwiz/src/surface/line.rs b/termwiz/src/surface/line.rs index a9ef00b21..5e2544332 100644 --- a/termwiz/src/surface/line.rs +++ b/termwiz/src/surface/line.rs @@ -28,8 +28,8 @@ bitflags! { #[cfg_attr(feature = "use_serde", derive(Serialize, Deserialize))] #[derive(Debug, Clone, PartialEq)] pub struct Line { - bits: LineBits, cells: Vec, + bits: LineBits, } #[derive(Debug, Clone, PartialEq)] @@ -367,6 +367,7 @@ impl Line { } self.cells.insert(x, cell); + self.set_dirty(); } pub fn erase_cell(&mut self, x: usize) { @@ -374,6 +375,7 @@ impl Line { self.invalidate_grapheme_at_or_before(x); self.cells.remove(x); self.cells.push(Cell::default()); + self.set_dirty(); } pub fn erase_cell_with_margin(&mut self, x: usize, right_margin: usize) { @@ -381,6 +383,7 @@ impl Line { self.invalidate_grapheme_at_or_before(x); self.cells.remove(x); self.cells.insert(right_margin - 1, Cell::default()); + self.set_dirty(); } pub fn fill_range(&mut self, cols: impl Iterator, cell: &Cell) { @@ -446,6 +449,7 @@ impl Line { pub fn set_last_cell_was_wrapped(&mut self, wrapped: bool) { if let Some(cell) = self.cells.last_mut() { cell.attrs_mut().set_wrapped(wrapped); + self.set_dirty(); } }