adobe/brackets — pull request #1596 by njx (2012-09-07 23:52:24+00:00)
Title: FOR REVIEW: Show code hints on change instead of keyup

This is a proposed fix for #1415, but I'm not totally sure we should merge it as-is. I'd like @RaymondLim and @peterflynn to take a look.

The change is the one Peter proposed in #1415--show the code hints on change instead of on keyup. A couple of questions about the fix:

* With the original setup, there was never any danger that you wouldn't eventually process the "showCodeHintsOnKeyUp" flag, because the browser (presumably) guarantees that you get a keyup for every keydown. However, with this fix, there's no guarantee you'll get a CodeMirror "change" event after a keydown. In general, you always should, because any key that would trigger code hints should theoretically cause a change event to happen eventually. But I just wanted another set of eyes on this to make sure there wasn't some other way to get into a state where "showCodeHintsOnChange" would end up being left hanging and not processed until some later unrelated change event.

* The way CodeHintManager is currently set up, it doesn't actually attach to/detach from the current editor to handle key events. Instead, there's just a hardcoded call to the CodeHintManager from Editor. I followed that same pattern for the change event handling, but it seems like a bad inverse dependency. Is there a reason we did it this way originally? Should we change it to attach/detach listeners as the current editor changes?