From 2ebc5d904dee1395e853bec22c48817fe1a128e9 Mon Sep 17 00:00:00 2001 From: Daniel Imms Date: Tue, 23 Jan 2018 06:51:22 -0800 Subject: [PATCH] Resize saved cursor position on buffer resize Saved cursor coordinates were not being resized as well which could lead to crashes when resizing down while the alt buffer is active. Fixes #1151 --- src/Buffer.ts | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/Buffer.ts b/src/Buffer.ts index 3e7d6122..39b0726c 100644 --- a/src/Buffer.ts +++ b/src/Buffer.ts @@ -177,16 +177,13 @@ export class Buffer implements IBuffer { } // Make sure that the cursor stays on screen - if (this.y >= newRows) { - this.y = newRows - 1; - } + this.x = Math.min(this.x, newCols - 1); + this.y = Math.min(this.y, newRows - 1); if (addToY) { this.y += addToY; } - - if (this.x >= newCols) { - this.x = newCols - 1; - } + this.savedY = Math.min(this.savedY, newRows - 1); + this.savedX = Math.min(this.savedX, newCols - 1); this.scrollTop = 0; }