Skip to content

Commit fda022d

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 5712e4a commit fda022d

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
@@ -973,8 +973,9 @@ class TextLinesMutator {
973973
this._curLine += newLines.length;
974974
// insert the remaining chars from the "old" line (e.g. the line we were in
975975
// when we started to insert new lines)
976-
this._curSplice.push(theLine.substring(lineCol));
977-
this._curCol = 0; // TODO(doc) why is this not set to the length of last line?
976+
const remaining = theLine.substring(lineCol);
977+
if (remaining !== '') this._curSplice.push(remaining);
978+
this._curCol = 0;
978979
} else {
979980
this._curSplice.push(...newLines);
980981
this._curLine += newLines.length;

0 commit comments

Comments
 (0)