fix: fix Terminal zoom inconsistency
This commit is contained in:
@@ -12,4 +12,4 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#define MONTAUK_BUILD_NUMBER 107
|
#define MONTAUK_BUILD_NUMBER 108
|
||||||
|
|||||||
@@ -795,11 +795,21 @@ static inline void terminal_resize(TerminalState* t, int new_cols, int new_rows)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int new_scrollback = keep - new_rows;
|
// Anchor the new visible region to the cursor's line. Treating the bottom
|
||||||
|
// new_rows of kept content as the screen (the naive keep - new_rows) only
|
||||||
|
// works when the screen is full: with a partly filled screen -- e.g. a
|
||||||
|
// shell prompt a few lines down with blank rows below it -- it would push
|
||||||
|
// the real text up into scrollback and drop the view onto the blank region,
|
||||||
|
// so a zoom appears to scroll down and strands the cursor in empty space.
|
||||||
|
// Instead pin the cursor to the bottom row when there is enough history
|
||||||
|
// above it, otherwise keep the content anchored at the top.
|
||||||
|
int abs_cursor_y = t->scrollback_lines + t->cursor_y - discard;
|
||||||
|
if (abs_cursor_y < 0) abs_cursor_y = 0;
|
||||||
|
int new_scrollback = abs_cursor_y - (new_rows - 1);
|
||||||
if (new_scrollback < 0) new_scrollback = 0;
|
if (new_scrollback < 0) new_scrollback = 0;
|
||||||
|
if (new_scrollback > t->max_scrollback) new_scrollback = t->max_scrollback;
|
||||||
|
|
||||||
// Adjust cursor
|
// Adjust cursor
|
||||||
int abs_cursor_y = t->scrollback_lines + t->cursor_y - discard;
|
|
||||||
int new_cursor_y = abs_cursor_y - new_scrollback;
|
int new_cursor_y = abs_cursor_y - new_scrollback;
|
||||||
if (new_cursor_y < 0) new_cursor_y = 0;
|
if (new_cursor_y < 0) new_cursor_y = 0;
|
||||||
if (new_cursor_y >= new_rows) new_cursor_y = new_rows - 1;
|
if (new_cursor_y >= new_rows) new_cursor_y = new_rows - 1;
|
||||||
|
|||||||
Reference in New Issue
Block a user