Skip to content
This repository has been archived by the owner on Sep 6, 2021. It is now read-only.

Iwehrman/rework code hint manager #2387

Merged
merged 17 commits into from
Dec 20, 2012

Conversation

iwehrman
Copy link
Contributor

Implements the revised code hinting API as described at https://github.com/adobe/brackets/wiki/New-Code-Hinting-API-Proposal. Along with the previous commits, this directly addresses #1624 and #2258. The API should be flexible enough to allow a solution to #2286 as well.

cc @joelrbrandt @RaymondLim

RaymondLim and others added 8 commits December 17, 2012 21:03
… Glenn. This change also makes the problematic shouldShowHintsOnKey api no longer needed. It also resolves the conflicts between two or more providers by allowing each provider to register its specificity.
…rking on requires to be called for every keystokes.
@ghost ghost assigned redmunds Dec 18, 2012
// so that we avoid registering a provider twice
var providerName;
for (providerName in hintProviders) {
if (hintProviders.hasOwnProperty(providerName)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The hintProviders object members (indexes?) are modes, so I think this code would be more clear if "providerName" was changed to "modeName".

} else if (this.selectedIndex !== -1 &&
(keyCode === KeyEvent.DOM_VK_RETURN || keyCode === KeyEvent.DOM_VK_TAB)) {
// Trigger a click handler to commmit the selected item
$(this.$hintMenu.find("li")[this.selectedIndex]).triggerHandler("click");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

First, you need to check to see if anything is selected. If nothing is selected, then return. Otherwise, event.preventDefault() will be called (below) and the Return or Tab will not get inserted into the page.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With the updated rotation logic, if nothing is selected then up/down navigation will always cause something to be selected. If the user presses tab/enter and nothing is selected, the default handler won't be prevented because the final else-if branch won't be entered and instead the final if-branch will return before the prevention.

@redmunds
Copy link
Contributor

Done with initial code review.

if (!_inSession(editor) && lastChar) {
_beginSession(editor);
} else if (_inSession(editor)) {
_updateHintList();
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This logic can be simplified:

        if (_inSession(editor)) {
            _updateHintList();
        } else {
            if (lastChar) {
                _beginSession(editor);
            }
        }

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep! Fixed.

@redmunds
Copy link
Contributor

Looks great. Merging. Thanks, Ian!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants