diff src/libvterm/src/screen.c @ 31433:c9da70c1e6d5 v9.0.1049

patch 9.0.1049: crash when opening a very small terminal window Commit: https://github.com/vim/vim/commit/67578e5bcf7404d40d42876b738b72e68add1a3e Author: Bram Moolenaar <Bram@vim.org> Date: Mon Dec 12 13:47:44 2022 +0000 patch 9.0.1049: crash when opening a very small terminal window Problem: Crash when opening a very small terminal window. Solution: Instead of crashing fix the cursor position. (closes https://github.com/vim/vim/issues/11697)
author Bram Moolenaar <Bram@vim.org>
date Mon, 12 Dec 2022 15:00:05 +0100
parents bf4f25d50fdd
children b13f723a7ec6
line wrap: on
line diff
--- a/src/libvterm/src/screen.c
+++ b/src/libvterm/src/screen.c
@@ -661,9 +661,15 @@ static void resize_buffer(VTermScreen *s
   }
 
   /* We really expect the cursor position to be set by now */
+  /* Unfortunately we do get here when "new_rows" is one.  We don't want
+   * to crash, so until the above code is fixed let's just set the cursor. */
   if(active && (new_cursor.row == -1 || new_cursor.col == -1)) {
-    fprintf(stderr, "screen_resize failed to update cursor position\n");
-    abort();
+    /* fprintf(stderr, "screen_resize failed to update cursor position\n");
+     * abort(); */
+    if (new_cursor.row < 0)
+      new_cursor.row = 0;
+    if (new_cursor.col < 0)
+      new_cursor.col = 0;
   }
 
   if(old_row >= 0 && bufidx == BUFIDX_PRIMARY) {