212212 * return {boolean}
213213 * Indicates whether the manager should follow hint insertion with an
214214 * explicit hint request.
215+ *
216+ *
217+ * # CodeHintProvider.insertHintOnTab
218+ *
219+ * type {?boolean} insertHintOnTab
220+ * Indicates whether the CodeHintManager should request that the provider of
221+ * the current session insert the currently selected hint on tab key events,
222+ * or if instead a tab character should be inserted into the editor. If omitted,
223+ * the fallback behavior is determined by the CodeHintManager. The default
224+ * behavior is to insert a tab character, but this can be changed with the
225+ * CodeHintManager.setInsertHintOnTab() method.
215226 */
216227
217228
@@ -237,6 +248,23 @@ define(function (require, exports, module) {
237248 deferredHints = null ,
238249 keyDownEditor = null ;
239250
251+
252+ var _insertHintOnTabDefault = false ;
253+
254+ /**
255+ * Determines the default behavior of the CodeHintManager on tab key events.
256+ * setInsertHintOnTab(true) indicates that the currently selected code hint
257+ * should be inserted on tab key events. setInsertHintOnTab(false) indicates
258+ * that a tab character should be inserted into the editor on tab key events.
259+ * The default behavior can be overridden by individual providers.
260+ *
261+ * @param {boolean } Indicates whether providers should insert the currently
262+ * selected hint on tab key events.
263+ */
264+ function setInsertHintOnTab ( insertHintOnTab ) {
265+ _insertHintOnTabDefault = insertHintOnTab ;
266+ }
267+
240268 /**
241269 * Comparator to sort providers from high to low priority
242270 */
@@ -439,9 +467,16 @@ define(function (require, exports, module) {
439467
440468 // If a provider is found, initialize the hint list and update it
441469 if ( sessionProvider ) {
470+ var insertHintOnTab ;
471+ if ( sessionProvider . insertHintOnTab !== undefined ) {
472+ insertHintOnTab = sessionProvider . insertHintOnTab ;
473+ } else {
474+ insertHintOnTab = _insertHintOnTabDefault ;
475+ }
476+
442477 sessionEditor = editor ;
443-
444- hintList = new CodeHintList ( sessionEditor ) ;
478+
479+ hintList = new CodeHintList ( sessionEditor , insertHintOnTab ) ;
445480 hintList . onSelect ( function ( hint ) {
446481 var restart = sessionProvider . insertHint ( hint ) ,
447482 previousEditor = sessionEditor ;
@@ -589,4 +624,5 @@ define(function (require, exports, module) {
589624 exports . handleChange = handleChange ;
590625 exports . registerHintProvider = registerHintProvider ;
591626 exports . hasValidExclusion = hasValidExclusion ;
627+ exports . setInsertHintOnTab = setInsertHintOnTab ;
592628} ) ;
0 commit comments