mirror of
https://github.com/wez/wezterm.git
synced 2024-12-25 14:22:37 +03:00
improve cursor position adjustment on resize
Avoids accidentally moving the y position of the cursor; previously we would keep it pinned to the physical viewport relative coordinate, but we didn't account for the implicit scroll that happens when making the window smaller, which meant that the shell would re-render its prompt with some artifacts during a resize.
This commit is contained in:
parent
e13b4f7dc9
commit
d91e384a7e
@ -707,13 +707,20 @@ impl TerminalState {
|
||||
pixel_width: usize,
|
||||
pixel_height: usize,
|
||||
) {
|
||||
// Compute the change in the height of the viewport;
|
||||
// we'll use this to adjust the cursor position below.
|
||||
let y_delta = (physical_rows as i64) - (self.screen().physical_rows as i64);
|
||||
self.screen.resize(physical_rows, physical_cols);
|
||||
self.scroll_region = 0..physical_rows as i64;
|
||||
self.pixel_height = pixel_height;
|
||||
self.pixel_width = pixel_width;
|
||||
self.tabs.resize(physical_cols);
|
||||
// Ensure that the cursor is within the new bounds of the screen
|
||||
self.set_cursor_pos(&Position::Relative(0), &Position::Relative(0));
|
||||
// Ensure that the cursor is within the new bounds of the screen.
|
||||
// If we made the window smaller then we will have scrolled the
|
||||
// viewport contents up by the delta.
|
||||
// If we've made it larger then we do not want to adjust the
|
||||
// cursor position
|
||||
self.set_cursor_pos(&Position::Relative(0), &Position::Relative(y_delta.min(0)));
|
||||
}
|
||||
|
||||
/// Clear the dirty flag for all dirty lines
|
||||
|
Loading…
Reference in New Issue
Block a user