fix undo index going out of bounds in some cases

Undoindex went a little wonky in some cases

For instance, hitting control Z over and over would make it negative and then while trying to prune the revisions it would get in an infinite loop.  There also were some oddities when undoing all the way to the first entry and it wouldn't prune them.
I'm not sure about this; undoIndex was originally an indication of your position within the undo-buffers; setting it onInput makes it more like a revisionId. Previously, undoIndex=null was an indication that ctr+z/y weren't used yet; that indication is now gone... Should we rename undoIndex; or could you move this back to onKeyup?

Something like ```undoIndex = undoIndex || revisions.length-1;```