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

Commit 93f22d8

Browse files
committed
Merge pull request #6984 from adobe/tom/codehints-on-tab
New Insert Code Hints with Tab Preference
2 parents 0270511 + c864a25 commit 93f22d8

2 files changed

Lines changed: 12 additions & 26 deletions

File tree

src/editor/CodeHintManager.js

Lines changed: 12 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@
225225
* or if instead a tab character should be inserted into the editor. If omitted,
226226
* the fallback behavior is determined by the CodeHintManager. The default
227227
* behavior is to insert a tab character, but this can be changed with the
228-
* CodeHintManager.setInsertHintOnTab() method.
228+
* insertHintOnTab Preference.
229229
*/
230230

231231

@@ -236,12 +236,13 @@ define(function (require, exports, module) {
236236
"use strict";
237237

238238
// Load dependent modules
239-
var Commands = require("command/Commands"),
240-
CommandManager = require("command/CommandManager"),
241-
EditorManager = require("editor/EditorManager"),
242-
Strings = require("strings"),
243-
KeyEvent = require("utils/KeyEvent"),
244-
CodeHintList = require("editor/CodeHintList").CodeHintList;
239+
var Commands = require("command/Commands"),
240+
CommandManager = require("command/CommandManager"),
241+
EditorManager = require("editor/EditorManager"),
242+
Strings = require("strings"),
243+
KeyEvent = require("utils/KeyEvent"),
244+
CodeHintList = require("editor/CodeHintList").CodeHintList,
245+
PreferencesManager = require("preferences/PreferencesManager");
245246

246247
var hintProviders = { "all" : [] },
247248
lastChar = null,
@@ -250,24 +251,11 @@ define(function (require, exports, module) {
250251
hintList = null,
251252
deferredHints = null,
252253
keyDownEditor = null;
253-
254254

255-
var _insertHintOnTabDefault = false;
256-
257-
/**
258-
* Determines the default behavior of the CodeHintManager on tab key events.
259-
* setInsertHintOnTab(true) indicates that the currently selected code hint
260-
* should be inserted on tab key events. setInsertHintOnTab(false) indicates
261-
* that a tab character should be inserted into the editor on tab key events.
262-
* The default behavior can be overridden by individual providers.
263-
*
264-
* @param {boolean} Indicates whether providers should insert the currently
265-
* selected hint on tab key events.
266-
*/
267-
function setInsertHintOnTab(insertHintOnTab) {
268-
_insertHintOnTabDefault = insertHintOnTab;
269-
}
270255

256+
PreferencesManager.definePreference("insertHintOnTab", "boolean", false);
257+
258+
271259
/**
272260
* Comparator to sort providers from high to low priority
273261
*/
@@ -474,7 +462,7 @@ define(function (require, exports, module) {
474462
if (sessionProvider.insertHintOnTab !== undefined) {
475463
insertHintOnTab = sessionProvider.insertHintOnTab;
476464
} else {
477-
insertHintOnTab = _insertHintOnTabDefault;
465+
insertHintOnTab = PreferencesManager.get("insertHintOnTab");
478466
}
479467

480468
sessionEditor = editor;
@@ -665,5 +653,4 @@ define(function (require, exports, module) {
665653
exports.isOpen = isOpen;
666654
exports.registerHintProvider = registerHintProvider;
667655
exports.hasValidExclusion = hasValidExclusion;
668-
exports.setInsertHintOnTab = setInsertHintOnTab;
669656
});

src/language/CodeInspection.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -446,7 +446,6 @@ define(function (require, exports, module) {
446446
updateListeners();
447447
if (!doNotSave) {
448448
prefs.set(PREF_ENABLED, _enabled);
449-
prefs.save();
450449
}
451450

452451
// run immediately

0 commit comments

Comments
 (0)