Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
terminal: Keep alternate screen bottom-aligned (#61325)
XiaoYan Li37b9fbf22bb3
diff --git a/crates/terminal_view/src/terminal_element.rs b/crates/terminal_view/src/terminal_element.rsindex 84c5f986617..5d94ff37aeb 100644--- a/crates/terminal_view/src/terminal_element.rs+++ b/crates/terminal_view/src/terminal_element.rs@@ -1035,7 +1035,8 @@ impl Element for TerminalElement {if matches!(self.terminal_view.read(cx).mode, TerminalMode::Standalone) {let should_anchor_to_bottom = {let content = self.terminal.read(cx).last_content();- content.scrolled_to_bottom && content.bottom_row_occupied+ content.mode.contains(Modes::ALT_SCREEN)+ || (content.scrolled_to_bottom && content.bottom_row_occupied)};let scale_factor = window.scale_factor();let line_height_pixels = px(line_height);diff --git a/crates/terminal_view/src/terminal_view.rs b/crates/terminal_view/src/terminal_view.rsindex 1e1c4b78190..3dad6134174 100644--- a/crates/terminal_view/src/terminal_view.rs+++ b/crates/terminal_view/src/terminal_view.rs@@ -3119,6 +3119,13 @@ mod tests {assert_eq!(bounds.bottom(), draw_size.height);}+ #[gpui::test]+ async fn test_short_alt_screen_stays_bottom_anchored_on_resize(cx: &mut TestAppContext) {+ let (bounds, draw_size) = draw_standalone_terminal(b"\x1b[?1049h$ ", cx).await;+ assert!(bounds.origin.y > px(0.));+ assert_eq!(bounds.bottom(), draw_size.height);+ }+#[gpui::test]async fn test_tab_content_shows_terminal_title_when_custom_title_directly_set_empty(cx: &mut TestAppContext,