From a61cb8e4e7aac966cff2fa92cef68ad5b0991d37 Mon Sep 17 00:00:00 2001 From: Nekrasov Pavel Date: Mon, 30 Sep 2024 16:50:16 +0200 Subject: [PATCH] Update textarea.js Fix for some corner cases --- lib/widgets/textarea.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/widgets/textarea.js b/lib/widgets/textarea.js index 60227d0e..2608159f 100644 --- a/lib/widgets/textarea.js +++ b/lib/widgets/textarea.js @@ -292,7 +292,12 @@ Textarea.prototype._listener = function(ch, key) { const cursorPosition = copy[currentLine].length + this.offsetX; if (copy[currentLine] === ''){ copy.splice(currentLine, 1); - }else{ + } else if (cursorPosition === 0) { + if (currentLine > 0){ + const currentLineString = copy.splice(currentLine, 1); + copy[currentLine - 1] += currentLineString; + } + } else { copy[currentLine] = copy[currentLine].slice(0, cursorPosition - 1) + copy[currentLine].slice(cursorPosition); } this.value = copy.join('\n');