Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions app/src/terminal/grid_renderer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1134,6 +1134,11 @@ fn render_grid_with_ligatures<'a>(
None => {
// If there are no non-empty cells in the entire row, we can skip it entirely
if marked_text.peek().is_none() {
if let Some(sampler) = bg_color_sampler.as_deref_mut() {
for _ in 0..grid.columns() {
sampler.sample(ColorU::transparent_black());
}
}
continue;
}
grid.columns() - 1
Expand Down
6 changes: 4 additions & 2 deletions app/src/terminal/model/terminal_model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2049,8 +2049,10 @@ impl TerminalModel {
.active_block_mut()
.set_saved_cursor(block_list_cursor);

// Reset alt screen contents.
let bg = self.alt_screen.grid_storage().cursor().template.bg;
// Reset alt screen contents. DECSET 1049 starts with a fresh
// alternate buffer; a transient SGR background from UI chrome like
// tmux's status line should not seed the entire pane.
let bg = ansi::Color::Named(ansi::NamedColor::Background);
self.alt_screen
.grid_storage_mut()
.region_mut(..)
Expand Down
25 changes: 25 additions & 0 deletions app/src/terminal/model/terminal_model_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -650,6 +650,31 @@ fn test_alt_screen_toggle() {
assert!(!terminal.alt_screen_active);
}

#[test]
fn test_enter_alt_screen_clears_with_default_background() {
let mut terminal = TerminalModel::mock(None, None);

terminal.terminal_attribute(ansi::Attr::Background(ansi::Color::Named(
ansi::NamedColor::Green,
)));
terminal.set_mode(ansi::Mode::SwapScreen {
save_cursor_and_clear_screen: true,
});

let grid = terminal.alt_screen().grid_handler();
for row in 0..grid.visible_rows() {
let row = grid.row(row).expect("visible row should exist");
for cell in &row[..] {
assert_eq!(cell.c, '\0');
assert_eq!(
cell.bg,
ansi::Color::Named(ansi::NamedColor::Background),
"alternate screen should not inherit transient primary-screen SGR background"
);
}
}
}

#[test]
fn test_reset_state() {
let mut terminal: TerminalModel = TerminalModel::mock(None, None);
Expand Down