marijnh/CodeMirror — pull request #1581 by mightyguava (2013-06-09 20:18:47+00:00)
Title: [vim keymap] Rewrite insert mode change recording

Implements the following parts of https://github.com/marijnh/CodeMirror/issues/1568

- [x] Refine change event merging algorithm to take into account deletions that exceed the bounds of the current edit: i.e. record deleting existing text that was not added in the current insert mode session.

Change event merging was completely overwritten. In VIM7, as far as my testing will tell, a discrete, repeatable edit is an edit made without moving the cursor. I tried to merge change events together by checking `from`, `to`, and `text.length` to determine whether consecutive change events are contiguous.

It ended up being much easier to check if there was cursorActivity not preceeded by a change. Maybe this'll end up biting me later.

@marijnh, just a suggestion, it may be useful to add an `end` attribute to each change event to indicate where the cursor is after a change. Since change events can be chained, checking after receiving the event doesn't work. Would make this type of merging much easier (though I ended up not taking this route).