Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

Fix positioning of terminal inline assist after clearing the screen (#34465)

Cole Milleraf0031ae8bef
diff --git a/crates/terminal_view/src/terminal_view.rs b/crates/terminal_view/src/terminal_view.rs
index bad3ebd479f..1cc1fbcf6f6 100644
--- a/crates/terminal_view/src/terminal_view.rs
+++ b/crates/terminal_view/src/terminal_view.rs
@@ -25,11 +25,11 @@ use terminal::{
TaskStatus, Terminal, TerminalBounds, ToggleViMode,
alacritty_terminal::{
index::Point,
- term::{TermMode, search::RegexSearch},
+ term::{TermMode, point_to_viewport, search::RegexSearch},
},
terminal_settings::{self, CursorShape, TerminalBlink, TerminalSettings, WorkingDirectory},
};
-use terminal_element::{TerminalElement, is_blank};
+use terminal_element::TerminalElement;
use terminal_panel::TerminalPanel;
use terminal_scrollbar::TerminalScrollHandle;
use terminal_slash_command::TerminalSlashCommand;
@@ -497,25 +497,14 @@ impl TerminalView {
};
let line_height = terminal.last_content().terminal_bounds.line_height;
- let mut terminal_lines = terminal.total_lines();
let viewport_lines = terminal.viewport_lines();
- if terminal.total_lines() == terminal.viewport_lines() {
- let mut last_line = None;
- for cell in terminal.last_content.cells.iter().rev() {
- if !is_blank(cell) {
- break;
- }
-
- let last_line = last_line.get_or_insert(cell.point.line);
- if *last_line != cell.point.line {
- terminal_lines -= 1;
- }
- *last_line = cell.point.line;
- }
- }
-
+ let cursor = point_to_viewport(
+ terminal.last_content.display_offset,
+ terminal.last_content.cursor.point,
+ )
+ .unwrap_or_default();
let max_scroll_top_in_lines =
- (block.height as usize).saturating_sub(viewport_lines.saturating_sub(terminal_lines));
+ (block.height as usize).saturating_sub(viewport_lines.saturating_sub(cursor.line + 1));
max_scroll_top_in_lines as f32 * line_height
}