summaryrefslogtreecommitdiff
path: root/src/screen.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/screen.c')
-rw-r--r--src/screen.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/src/screen.c b/src/screen.c
index bd65564..1712faf 100644
--- a/src/screen.c
+++ b/src/screen.c
@@ -1236,6 +1236,14 @@ static bool term_resize_internal(struct term *t, int cols, int rows)
int old_cols = active_scr->cols;
int old_rows = active_scr->rows;
+ struct screen new_scr;
+ if (!resize_target(t, &new_scr, cols, rows, active_scr)) {
+ term_gstore_unpin(t->gstore);
+ return false;
+ }
+
+ /* Allocate the replacement before scrolling rows into history. A
+ * failed height shrink must leave the active screen and cursor alone. */
if (rows < old_rows && t->cursor_y >= rows) {
int shift = t->cursor_y - rows + 1;
for (int i = 0; i < shift; i++)
@@ -1243,12 +1251,10 @@ static bool term_resize_internal(struct term *t, int cols, int rows)
t->cursor_y -= shift;
t->saved.y = t->saved.y >= shift ? t->saved.y - shift : 0;
}
-
- struct screen new_scr;
- if (!resize_target(t, &new_scr, cols, rows, active_scr)) {
- term_gstore_unpin(t->gstore);
- return false;
- }
+ /* Scrolling can advance the screen's history mapping when there is
+ * no history buffer, so capture its final value after the scroll. */
+ new_scr.top_id = active_scr->top_id;
+ new_scr.top_seg = active_scr->top_seg;
int pull = 0;
if (rows > old_rows && !t->alternate)