code: function clearSelectionEvents(array) {
      while (array.length) {
        var last = lst(array);
        if (last.ranges) array.pop();
        else break;
      }
    }
docs: Pop all selection events off the end of a history array. Stop at a change event.