Skip to content

Commit 5712e4a

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 cfc0848 commit 5712e4a

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
@@ -979,11 +979,17 @@ class TextLinesMutator {
979979
this._curSplice.push(...newLines);
980980
this._curLine += newLines.length;
981981
}
982-
} else {
982+
} else if (!this.hasMore()) {
983983
// There are no additional lines. Although the line is put into splice, curLine is not
984-
// increased because there may be more chars in the line (newline is not reached).
984+
// increased because there may be more chars in the line (newline is not reached). We are
985+
// inserting at the end of lines. curCol is 0 as curLine is not in splice.
986+
this._curSplice.push(text);
987+
this._curCol += text.length;
988+
} else {
989+
// insert text after curCol
985990
const sline = this._putCurLineInSplice();
986991
if (!this._curSplice[sline]) {
992+
// TODO should never happen now
987993
const err = new Error(
988994
'curSplice[sline] not populated, actual curSplice contents is ' +
989995
`${JSON.stringify(this._curSplice)}. Possibly related to ` +

0 commit comments

Comments
 (0)