From b31638a630f175c6f59996f7f1949563cdcd5cc8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aleksandar=20Popadi=C4=87?= Date: Mon, 2 Dec 2013 21:51:03 +0100 Subject: [PATCH] Fix resize from width=1 to wider. Test Plan: Shrink terminal to width=1 and expand. Empty lines appear above prompt line. Reviewers: billiob Differential Revision: https://phab.enlightenment.org/D361 --- src/bin/termpty.c | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/src/bin/termpty.c b/src/bin/termpty.c index 4ffe49fd..5f711d5f 100644 --- a/src/bin/termpty.c +++ b/src/bin/termpty.c @@ -741,7 +741,6 @@ termpty_resize(Termpty *ty, int new_w, int new_h) int i; if ((ty->w == new_w) && (ty->h == new_h)) return; - if ((new_w == new_h) && (new_w == 1)) return; termpty_save_freeze(); @@ -766,12 +765,23 @@ termpty_resize(Termpty *ty, int new_w, int new_h) new_back = calloc(sizeof(Termsave *), ty->backmax); y_end = ty->state.cy; - y_start = termpty_line_find_top(ty, ty->state.cy); - new_y_start = new_h - 1 - (y_end - y_start); - new_y_end = new_y_start - 1; + y_start = termpty_line_find_top(ty, y_end); + if (ty->w == 1) + { + new_y_start = new_h - 1; + new_y_end = new_y_start - 1; + } + else + { + new_y_start = new_h - 1 - (y_end - y_start); + new_y_end = new_y_start - 1; + if (new_y_end < 0) + { + new_y_start = 0; + new_y_end = -1; + } + } y_end = y_start - 1; - if (new_y_end < 0) - new_y_end = -1; while ((y_end >= -ty->backscroll_num) && (new_y_end >= -ty->backmax)) { y_start = termpty_line_find_top(ty, y_end);