Skip to content

Commit

Permalink
textLinesMutator: fix insertions with newlines at the end of a line. In
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
webzwo0i authored and rhansen committed Nov 9, 2021
1 parent af7b5d1 commit c579c86
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/static/js/Changeset.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit c579c86

Please sign in to comment.