Skip to content

Commit

Permalink
Properly track event count when rebasing
Browse files Browse the repository at this point in the history
  • Loading branch information
marijnh committed Feb 2, 2017
1 parent 09278fe commit f15fde9
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/history.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ class Branch {

let mapping = rebasedTransform.mapping
let newUntil = rebasedTransform.steps.length
let eventCount = this.eventCount

let iRebased = startPos
this.items.forEach(item => {
Expand All @@ -151,6 +152,7 @@ class Branch {
let selection = item.selection && Selection.mapJSON(item.selection, mapping.slice(iRebased - 1, pos))
rebasedItems.push(new Item(map, step, selection))
} else {
if (item.selection) eventCount--
rebasedItems.push(new Item(map))
}
}, start)
Expand All @@ -159,7 +161,7 @@ class Branch {
for (let i = rebasedCount; i < newUntil; i++)
newMaps.push(new Item(mapping.maps[i]))
let items = this.items.slice(0, start).append(newMaps).append(rebasedItems)
let branch = new Branch(items, this.eventCount) // FIXME might update event count
let branch = new Branch(items, eventCount)
if (branch.emptyItemCount() > max_empty_items)
branch = branch.compress(this.items.length - rebasedItems.length)
return branch
Expand Down

0 comments on commit f15fde9

Please sign in to comment.