(doc, sel, opId, options)
| 6720 | // selection into the 'done' array when it was significantly |
| 6721 | // different (in number of selected ranges, emptiness, or time). |
| 6722 | function addSelectionToHistory(doc, sel, opId, options) { |
| 6723 | var hist = doc.history, |
| 6724 | origin = options && options.origin |
| 6725 | |
| 6726 | // A new event is started when the previous origin does not match |
| 6727 | // the current, or the origins don't allow matching. Origins |
| 6728 | // starting with * are always merged, those starting with + are |
| 6729 | // merged when similar and close together in time. |
| 6730 | if (opId == hist.lastSelOp || (origin && hist.lastSelOrigin == origin && ((hist.lastModTime == hist.lastSelTime && hist.lastOrigin == origin) || selectionEventCanBeMerged(doc, origin, lst(hist.done), sel)))) { |
| 6731 | hist.done[hist.done.length - 1] = sel |
| 6732 | } else { |
| 6733 | pushSelectionToHistory(sel, hist.done) |
| 6734 | } |
| 6735 | |
| 6736 | hist.lastSelTime = +new Date() |
| 6737 | hist.lastSelOrigin = origin |
| 6738 | hist.lastSelOp = opId |
| 6739 | if (options && options.clearRedo !== false) { |
| 6740 | clearSelectionEvents(hist.undone) |
| 6741 | } |
| 6742 | } |
| 6743 | |
| 6744 | function pushSelectionToHistory(sel, dest) { |
| 6745 | var top = lst(dest) |
no test coverage detected