Skip to content

Commit 11f3d96

Browse files
committed
[merge addon] Correctly compute chunk start when copying at end of document
Closes codemirror#3802
1 parent 8799d1d commit 11f3d96

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

addon/merge/merge.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -427,9 +427,9 @@
427427

428428
function copyChunk(dv, to, from, chunk) {
429429
if (dv.diffOutOfDate) return;
430-
var start = chunk.editTo > to.lastLine() ? Pos(chunk.editFrom - 1) : Pos(chunk.editFrom, 0)
431-
to.replaceRange(from.getRange(Pos(chunk.origFrom, 0), Pos(chunk.origTo, 0)),
432-
start, Pos(chunk.editTo, 0));
430+
var editStart = chunk.editTo > to.lastLine() ? Pos(chunk.editFrom - 1) : Pos(chunk.editFrom, 0)
431+
var origStart = chunk.origTo > from.lastLine() ? Pos(chunk.origFrom - 1) : Pos(chunk.origFrom, 0)
432+
to.replaceRange(from.getRange(origStart, Pos(chunk.origTo, 0)), editStart, Pos(chunk.editTo, 0))
433433
}
434434

435435
// Merge view, containing 0, 1, or 2 diff views.

0 commit comments

Comments
 (0)