From 1006608093fbbe19103f63fc1140b122a3904500 Mon Sep 17 00:00:00 2001 From: Daniel Eklöf Date: Mon, 16 Mar 2020 12:00:25 +0100 Subject: alt-screen: use a custom 'saved' cursor when switching to alt screen This fixes an issue where we failed to restore the cursor correctly when exiting from the alternate screen, if the client had sent escapes to save the cursor position while inside the alternate screen. This was because we used the *same* storage for saving the cursor position through escapes, as for saving it when entering the alternate screen. Fix by using a custom variable dedicated to normal <--> alt screen switching. --- terminal.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'terminal.c') diff --git a/terminal.c b/terminal.c index 17233690..552b8d2a 100644 --- a/terminal.c +++ b/terminal.c @@ -1120,7 +1120,7 @@ term_reset(struct terminal *term, bool hard) if (term->grid == &term->alt) { term->grid = &term->normal; - term_restore_cursor(term); + term_restore_cursor(term, &term->alt_saved_cursor); selection_cancel(term); } @@ -1645,12 +1645,12 @@ term_reset_view(struct terminal *term) } void -term_restore_cursor(struct terminal *term) +term_restore_cursor(struct terminal *term, const struct cursor *cursor) { - int row = min(term->saved_cursor.point.row, term->rows - 1); - int col = min(term->saved_cursor.point.col, term->cols - 1); + int row = min(cursor->point.row, term->rows - 1); + int col = min(cursor->point.col, term->cols - 1); term_cursor_to(term, row, col); - term->cursor.lcf = term->saved_cursor.lcf; + term->cursor.lcf = cursor->lcf; } void -- cgit v1.3