(doc, sel, opId, options)
| 7972 | // selection into the 'done' array when it was significantly |
| 7973 | // different (in number of selected ranges, emptiness, or time). |
| 7974 | function addSelectionToHistory(doc, sel, opId, options) { |
| 7975 | var hist = doc.history, origin = options && options.origin; |
| 7976 | |
| 7977 | // A new event is started when the previous origin does not match |
| 7978 | // the current, or the origins don't allow matching. Origins |
| 7979 | // starting with * are always merged, those starting with + are |
| 7980 | // merged when similar and close together in time. |
| 7981 | if (opId == hist.lastSelOp || |
| 7982 | (origin && hist.lastSelOrigin == origin && |
| 7983 | (hist.lastModTime == hist.lastSelTime && hist.lastOrigin == origin || |
| 7984 | selectionEventCanBeMerged(doc, origin, lst(hist.done), sel)))) |
| 7985 | hist.done[hist.done.length - 1] = sel; |
| 7986 | else |
| 7987 | pushSelectionToHistory(sel, hist.done); |
| 7988 | |
| 7989 | hist.lastSelTime = +new Date; |
| 7990 | hist.lastSelOrigin = origin; |
| 7991 | hist.lastSelOp = opId; |
| 7992 | if (options && options.clearRedo !== false) |
| 7993 | clearSelectionEvents(hist.undone); |
| 7994 | } |
| 7995 | |
| 7996 | function pushSelectionToHistory(sel, dest) { |
| 7997 | var top = lst(dest); |
no test coverage detected