From c579c86d2ea8211e0f29e1b1031880941ca04068 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 cf2b565adee..7419d37519d 100644 --- a/src/static/js/Changeset.js +++ b/src/static/js/Changeset.js @@ -924,8 +924,9 @@ exports.textLinesMutator = (lines) => { 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) - curSplice.push(theLine.substring(lineCol)); - curCol = 0; // TODO(doc) why is this not set to the length of last line? + const remaining = theLine.substring(lineCol); + if (remaining !== '') curSplice.push(remaining); + curCol = 0; } else { Array.prototype.push.apply(curSplice, newLines); curLine += newLines.length;