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);