(doc, sel, opId, options)
| 4909 | // selection into the 'done' array when it was significantly |
| 4910 | // different (in number of selected ranges, emptiness, or time). |
| 4911 | function addSelectionToHistory(doc, sel, opId, options) { |
| 4912 | var hist = doc.history, origin = options && options.origin; |
| 4913 | |
| 4914 | // A new event is started when the previous origin does not match |
| 4915 | // the current, or the origins don't allow matching. Origins |
| 4916 | // starting with * are always merged, those starting with + are |
| 4917 | // merged when similar and close together in time. |
| 4918 | if (opId == hist.lastSelOp || |
| 4919 | (origin && hist.lastSelOrigin == origin && |
| 4920 | (hist.lastModTime == hist.lastSelTime && hist.lastOrigin == origin || |
| 4921 | selectionEventCanBeMerged(doc, origin, lst(hist.done), sel)))) |
| 4922 | { hist.done[hist.done.length - 1] = sel; } |
| 4923 | else |
| 4924 | { pushSelectionToHistory(sel, hist.done); } |
| 4925 | |
| 4926 | hist.lastSelTime = +new Date; |
| 4927 | hist.lastSelOrigin = origin; |
| 4928 | hist.lastSelOp = opId; |
| 4929 | if (options && options.clearRedo !== false) |
| 4930 | { clearSelectionEvents(hist.undone); } |
| 4931 | } |
| 4932 | |
| 4933 | function pushSelectionToHistory(sel, dest) { |
| 4934 | var top = lst(dest); |
no test coverage detected