Skip to content

Commit f4dd9cd

Browse files
webzwo0irhansen
authored andcommitted
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.
1 parent a986145 commit f4dd9cd

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/static/js/Changeset.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -882,8 +882,9 @@ const textLinesMutator = (lines) => {
882882
curLine += newLines.length;
883883
// insert the remaining chars from the "old" line (e.g. the line we were in
884884
// when we started to insert new lines)
885-
curSplice.push(theLine.substring(lineCol));
886-
curCol = 0; // TODO(doc) why is this not set to the length of last line?
885+
const remaining = theLine.substring(lineCol);
886+
if (remaining !== '') curSplice.push(remaining);
887+
curCol = 0;
887888
} else {
888889
curSplice.push(...newLines);
889890
curLine += newLines.length;

0 commit comments

Comments
 (0)