(doc, sel, opId, options)
| 6639 | // selection into the 'done' array when it was significantly |
| 6640 | // different (in number of selected ranges, emptiness, or time). |
| 6641 | function addSelectionToHistory(doc, sel, opId, options) { |
| 6642 | var hist = doc.history, origin = options && options.origin; |
| 6643 | |
| 6644 | // A new event is started when the previous origin does not match |
| 6645 | // the current, or the origins don't allow matching. Origins |
| 6646 | // starting with * are always merged, those starting with + are |
| 6647 | // merged when similar and close together in time. |
| 6648 | if (opId == hist.lastOp || |
| 6649 | (origin && hist.lastSelOrigin == origin && |
| 6650 | (hist.lastModTime == hist.lastSelTime && hist.lastOrigin == origin || |
| 6651 | selectionEventCanBeMerged(doc, origin, lst(hist.done), sel)))) |
| 6652 | hist.done[hist.done.length - 1] = sel; |
| 6653 | else |
| 6654 | pushSelectionToHistory(sel, hist.done); |
| 6655 | |
| 6656 | hist.lastSelTime = +new Date; |
| 6657 | hist.lastSelOrigin = origin; |
| 6658 | hist.lastOp = opId; |
| 6659 | if (options && options.clearRedo !== false) |
| 6660 | clearSelectionEvents(hist.undone); |
| 6661 | } |
| 6662 | |
| 6663 | function pushSelectionToHistory(sel, dest) { |
| 6664 | var top = lst(dest); |
no test coverage detected