Skip to content

Commit f4c6a9b

Browse files
committed
textLinesMutator: Fix insertions at the end of lines. The new
insertions are directly pushed to curSplice now instead of incorporating an undefined line into the splice.
1 parent 243d4ae commit f4c6a9b

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/static/js/Changeset.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -921,12 +921,18 @@ exports.textLinesMutator = (lines) => {
921921
Array.prototype.push.apply(curSplice, newLines);
922922
curLine += newLines.length;
923923
}
924-
} else {
924+
} else if (!hasMore()) {
925925
// there are no additional lines
926926
// although the line is put into splice, curLine is not increased, because
927927
// there may be more chars in the line (newline is not reached)
928+
// we are inserting at the end of lines. curCol is 0 as curLine is not in splice
929+
curSplice.push(text);
930+
curCol += text.length;
931+
} else {
932+
// insert text after curCol
928933
const sline = putCurLineInSplice();
929934
if (!curSplice[sline]) {
935+
// TODO should never happen now
930936
console.error('curSplice[sline] not populated, actual curSplice contents is ', curSplice, '. Possibly related to https://github.com/ether/etherpad-lite/issues/2802');
931937
}
932938
curSplice[sline] = curSplice[sline].substring(0, curCol) + text +

0 commit comments

Comments
 (0)