GlobalKeymap.bindKey can take a selector and a custom function that
maps key events to commands. If it returns false, no command is
triggered but event propagation is halted.
Vim mode has an operator stack. Every time an operator is pushed to the
stack, we ask if it is complete. If it's complete, we compose it with
the operator below it, then pop that operator if its complete. When no
operators remain on the stack, we call execute the final composed
operator. So far we only have DeleteChar (x) and NumericPrefix
operators.
We just capture focusout events on root view… if anything other than the editors text area lost focus, we focus the editor again. This will likely need refinement when we add more widgets to the system, but its enough to make the fuzzy finder behave appropriately.
Also fixed a bug where the GlobalKeymap wasn't returning true when it
matched a binding, which caused key events to be processed twice when
they bubbled out of the editor and hit the root view.
Ace triggers key handlers for both keydown (onCommandKey) and input
(onTextInput) events. Input events don't pass the event, which was
blowing up the keymap.
Now if a keypress event bubbles to an element with bindings for
multiple matching selectors, the most specific selector is chosen. This
allows us to override a keybinding by using a more specific selector.
For example, say we have an editor instance inside of the file-finder
widget, so that the user can use all their normal bindings when they
type the name of the file. Except when they hit <esc> we want to close
the file finder, not do whatever they normally have it bound to. Now we
can just say:
```
.file-finder .editor {
<esc>: close-file-finder
}
```
And we're assured that our binding will take precedence.
Say we have a structure like:
div.parent
div.child
div.grandchild
And we have two mappings:
.parent { x: foo }
.child { x:bar }
If there's an event originating on grandchild, it will *only* trigger
bar, because that selector selects a closer ancestor.
KeyEventHandler holds references to BindingSets. The name "binding set"
is based on the concept of a CSS ruleset. The idea is to choose a key
binding for an event based on what selectors (match / most closely
contain) the event's target DOM node.
If we have pattern 'da' and 'dad' both mapped, when 'da' is typed, the KeyMap waits for a given timeout for another character to be entered. If the time elapses, it goes ahead and executes the action for 'da'. But if a 'd' is subsequently entered, it executes 'dad'.
Rename FileSystemHelper-contentsOfDirectoryAtPath… to -listFilesAtPath to make it clear that we're only listing files, not subdirectories. This is a fairly special purpose method but it saves us from calling back into objective-c a ton of times to filter them in JS, and makes bringing up the file finder ~2x as fast.