Skip to content

Commit a986145

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 c558d79 commit a986145

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/static/js/Changeset.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -888,11 +888,17 @@ const textLinesMutator = (lines) => {
888888
curSplice.push(...newLines);
889889
curLine += newLines.length;
890890
}
891-
} else {
891+
} else if (!hasMore()) {
892892
// There are no additional lines. Although the line is put into splice, curLine is not
893-
// increased because there may be more chars in the line (newline is not reached).
893+
// increased because there may be more chars in the line (newline is not reached). We are
894+
// inserting at the end of lines. curCol is 0 as curLine is not in splice.
895+
curSplice.push(text);
896+
curCol += text.length;
897+
} else {
898+
// insert text after curCol
894899
const sline = putCurLineInSplice();
895900
if (!curSplice[sline]) {
901+
// TODO should never happen now
896902
const err = new Error(
897903
'curSplice[sline] not populated, actual curSplice contents is ' +
898904
`${JSON.stringify(curSplice)}. Possibly related to ` +

0 commit comments

Comments
 (0)