(doc, sel, opId, options)
| 8004 | // selection into the 'done' array when it was significantly |
| 8005 | // different (in number of selected ranges, emptiness, or time). |
| 8006 | function addSelectionToHistory(doc, sel, opId, options) { |
| 8007 | var hist = doc.history, origin = options && options.origin; |
| 8008 | |
| 8009 | // A new event is started when the previous origin does not match |
| 8010 | // the current, or the origins don't allow matching. Origins |
| 8011 | // starting with * are always merged, those starting with + are |
| 8012 | // merged when similar and close together in time. |
| 8013 | if (opId == hist.lastSelOp || |
| 8014 | (origin && hist.lastSelOrigin == origin && |
| 8015 | (hist.lastModTime == hist.lastSelTime && hist.lastOrigin == origin || |
| 8016 | selectionEventCanBeMerged(doc, origin, lst(hist.done), sel)))) |
| 8017 | hist.done[hist.done.length - 1] = sel; |
| 8018 | else |
| 8019 | pushSelectionToHistory(sel, hist.done); |
| 8020 | |
| 8021 | hist.lastSelTime = +new Date; |
| 8022 | hist.lastSelOrigin = origin; |
| 8023 | hist.lastSelOp = opId; |
| 8024 | if (options && options.clearRedo !== false) |
| 8025 | clearSelectionEvents(hist.undone); |
| 8026 | } |
| 8027 | |
| 8028 | function pushSelectionToHistory(sel, dest) { |
| 8029 | var top = lst(dest); |
no test coverage detected