Skip to content

Commit af7b5d1

Browse files
webzwo0irhansen
authored andcommitted
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 0af1eea commit af7b5d1

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
@@ -930,12 +930,18 @@ exports.textLinesMutator = (lines) => {
930930
Array.prototype.push.apply(curSplice, newLines);
931931
curLine += newLines.length;
932932
}
933-
} else {
933+
} else if (!hasMore()) {
934934
// there are no additional lines
935935
// although the line is put into splice, curLine is not increased, because
936936
// there may be more chars in the line (newline is not reached)
937+
// we are inserting at the end of lines. curCol is 0 as curLine is not in splice
938+
curSplice.push(text);
939+
curCol += text.length;
940+
} else {
941+
// insert text after curCol
937942
const sline = putCurLineInSplice();
938943
if (!curSplice[sline]) {
944+
// TODO should never happen now
939945
console.error('curSplice[sline] not populated, actual curSplice contents is ', curSplice, '. Possibly related to https://github.com/ether/etherpad-lite/issues/2802');
940946
}
941947
curSplice[sline] = curSplice[sline].substring(0, curCol) + text +

0 commit comments

Comments
 (0)