adobe/brackets — pull request #4173 by njx (2013-06-10 01:52:05+00:00)
Title: Ignore key and close code hint session if code hint list is invisible

For #4172.

The issue is the long-standing one of dropdowns not notifying us when they close due to the user clicking out (because Bootstrap just takes the class off the dropdown--there's no notification mechanism). This basically just checks in the keydown handler if we're no longer visible, and if so ends the session.

I'm not absolutely certain of this fix (though it's better than nothing). The issue is that the original key handling code, which was in CodeHintManager, would check a couple of other things besides `CodeHintList.isOpen()` before deciding whether to dispatch a key. I *think* that in the case where the CodeHintList is actually handling the keydown, we only care about whether it's open.

In general, I think we need to clean up the control flow between CodeHintManager and CodeHintList...the fact that CodeHintManager knows about "sessions" but CodeHintList doesn't makes it hard to make the logic totally consistent here. Another symptom of this is that CHL can't just close itself, but calls a callback that is really just CodeHintManager's `_endSession()`. We should probably use events for that instead.