From 76197a196bea799d4a475b46921fd591abd7b20a Mon Sep 17 00:00:00 2001 From: webzwo0i Date: Sun, 31 Oct 2021 00:17:48 +0200 Subject: [PATCH] textLinesMutator: Fix insertions with newlines at the end of a line In such cases the remaining part of the old line is directly pushed to the splice and we need to ensure it is not an empty string. --- src/static/js/Changeset.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/static/js/Changeset.js b/src/static/js/Changeset.js index f3ad88cb3ca9..58e16725cca1 100644 --- a/src/static/js/Changeset.js +++ b/src/static/js/Changeset.js @@ -973,8 +973,9 @@ class TextLinesMutator { this._curLine += newLines.length; // insert the remaining chars from the "old" line (e.g. the line we were in // when we started to insert new lines) - this._curSplice.push(theLine.substring(lineCol)); - this._curCol = 0; // TODO(doc) why is this not set to the length of last line? + const remaining = theLine.substring(lineCol); + if (remaining !== '') this._curSplice.push(remaining); + this._curCol = 0; } else { this._curSplice.push(...newLines); this._curLine += newLines.length;