When assigning the cursor's position, if we decide we want to autoscroll,
we should do so even if the cursor's position doesn't change.
The previous approach relied on a comparison of the position being
assigned, but this is before it has been clipped. Now we rely on a
boolean return value from the marker position assignment methods, which
tells us if the position has changed. If not, we need to emit our own
event to force autoscrolling.
This is needed by the snippets package, which needs to know where the
cursor was previously when it moves to decide whether to cancel the
current snippet.
This is used by cursor to only autoscroll when the marker head is
explicitly moved, so that passive movements caused by buffer insertions
don't trigger autoscrolling.
This commit makes autoscroll a 3-valued property on the cursor. If it
is set to true or false, that setting will stick until the cursor's
next visual update. That means we can explicitly move the cursor with
autoscroll set to false, but also still autoscroll by default when the
cursor's anchor moves on its own.
Previously if null was returned for the end of word position then
it was interpreted as 0,0 which would select the entire contents
before the current word instead of the current word.
Any events emitted from DOM nodes should be prefixed with an identifier
for the node that emits them. This eliminates the possibility of ambiguity
when the events bubble up the DOM away from their emitter.
For this to work, I needed to make the updating of anchors transactional. Now, all anchors are updated and *then* they emit their events. That way when the cursor moves based on the user typing, the tab stop they're in has a chance to expand before we handle the move event. This prevents spurious cancellation of the snippet when typing on a tab stop.
If the input element is a child of the scroll view, then focusing it can end up changing the scroll position of the view behind our backs. We *only* want to scroll the view via our interface on editor, because a bunch of of special code needs to run when we scroll. We can't just have the browser scrolling that view around willy-nilly.
This does *not* include newlines. Doing this makes it possible to double-click regions of whitespace to select them just as you can select a word. It also makes word movement bindings behave similarly to TextMate.
If we're pasting multiple lines starting inside an already existing line, we never want to auto indent. We should just take its existing indentation level. Also, we strip the leading whitespace off the first line we're inserting, assuming it's already being represented by the indentation of the line we're onto which we're appending it.