This repository was archived by the owner on Sep 6, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7.5k
Make code hint insertion on tab key configurable #5084
Merged
Merged
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -212,6 +212,17 @@ | |
| * return {boolean} | ||
| * Indicates whether the manager should follow hint insertion with an | ||
| * explicit hint request. | ||
| * | ||
| * | ||
| * # CodeHintProvider.insertHintOnTab | ||
| * | ||
| * type {?boolean} insertHintOnTab | ||
| * Indicates whether the CodeHintManager should request that the provider of | ||
| * the current session insert the currently selected hint on tab key events, | ||
| * or if instead a tab character should be inserted into the editor. If omitted, | ||
| * the fallback behavior is determined by the CodeHintManager. The default | ||
| * behavior is to insert a tab character, but this can be changed with the | ||
| * CodeHintManager.setInsertHintOnTab() method. | ||
| */ | ||
|
|
||
|
|
||
|
|
@@ -237,6 +248,23 @@ define(function (require, exports, module) { | |
| deferredHints = null, | ||
| keyDownEditor = null; | ||
|
|
||
|
|
||
| var _insertHintOnTabDefault = false; | ||
|
|
||
| /** | ||
| * Determines the default behavior of the CodeHintManager on tab key events. | ||
| * setInsertHintOnTab(true) indicates that the currently selected code hint | ||
| * should be inserted on tab key events. setInsertHintOnTab(false) indicates | ||
| * that a tab character should be inserted into the editor on tab key events. | ||
| * The default behavior can be can be overridden by individual providers. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Duplicate "can be" on this line. |
||
| * | ||
| * @param {boolean} Indicates whether providers should insert the currently | ||
| * selected hint on tab key events. | ||
| */ | ||
| function setInsertHintOnTab(insertHintOnTab) { | ||
| _insertHintOnTabDefault = insertHintOnTab; | ||
| } | ||
|
|
||
| /** | ||
| * Comparator to sort providers from high to low priority | ||
| */ | ||
|
|
@@ -439,9 +467,16 @@ define(function (require, exports, module) { | |
|
|
||
| // If a provider is found, initialize the hint list and update it | ||
| if (sessionProvider) { | ||
| var insertHintOnTab; | ||
| if (sessionProvider.insertHintOnTab !== undefined) { | ||
| insertHintOnTab = sessionProvider.insertHintOnTab; | ||
| } else { | ||
| insertHintOnTab = _insertHintOnTabDefault; | ||
| } | ||
|
|
||
| sessionEditor = editor; | ||
|
|
||
| hintList = new CodeHintList(sessionEditor); | ||
| hintList = new CodeHintList(sessionEditor, insertHintOnTab); | ||
| hintList.onSelect(function (hint) { | ||
| var restart = sessionProvider.insertHint(hint), | ||
| previousEditor = sessionEditor; | ||
|
|
@@ -589,4 +624,5 @@ define(function (require, exports, module) { | |
| exports.handleChange = handleChange; | ||
| exports.registerHintProvider = registerHintProvider; | ||
| exports.hasValidExclusion = hasValidExclusion; | ||
| exports.setInsertHintOnTab = setInsertHintOnTab; | ||
| }); | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: We're not in callback function. So "self" and "this" here are the same, but for consistency with neighboring code, I think we should just use "this" here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whoops! I got lost in the scope hierarchy. Thanks!