Skip to content

Commit

Permalink
textLinesMutator: Fix insertions at the end of lines. The new
Browse files Browse the repository at this point in the history
insertions are directly pushed to curSplice now instead of incorporating
an undefined line into the splice.
  • Loading branch information
webzwo0i authored and rhansen committed Nov 9, 2021
1 parent 0af1eea commit af7b5d1
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/static/js/Changeset.js
Original file line number Diff line number Diff line change
Expand Up @@ -930,12 +930,18 @@ exports.textLinesMutator = (lines) => {
Array.prototype.push.apply(curSplice, newLines);
curLine += newLines.length;
}
} else {
} else if (!hasMore()) {
// there are no additional lines
// although the line is put into splice, curLine is not increased, because
// there may be more chars in the line (newline is not reached)
// we are inserting at the end of lines. curCol is 0 as curLine is not in splice
curSplice.push(text);
curCol += text.length;
} else {
// insert text after curCol
const sline = putCurLineInSplice();
if (!curSplice[sline]) {
// TODO should never happen now
console.error('curSplice[sline] not populated, actual curSplice contents is ', curSplice, '. Possibly related to https://github.com/ether/etherpad-lite/issues/2802');
}
curSplice[sline] = curSplice[sline].substring(0, curCol) + text +
Expand Down

0 comments on commit af7b5d1

Please sign in to comment.