mirror of
https://github.com/RustyRaptor/brackets.git
synced 2026-12-04 00:15:22 -07:00
add pref to prevent js code hints on dot
This commit is contained in:
1 parent
14cce3d4ac
commit
e43a49f576
2 files changed
+13
-4
No files matched your search
@@ -97,11 +97,12 @@ define(function (require, exports, module) {
|
||||
* Determine if hints should be displayed for the given key.
|
||||
*
|
||||
* @param {string} key - key entered by the user
|
||||
* @param {boolean} showOnDot - show hints on dot (".").
|
||||
* @return {boolean} true if the hints should be shown for the key,
|
||||
* false otherwise.
|
||||
*/
|
||||
function hintableKey(key) {
|
||||
return (key === null || key === "." || maybeIdentifier(key));
|
||||
function hintableKey(key, showOnDot) {
|
||||
return (key === null || (showOnDot && key === ".") || maybeIdentifier(key));
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -55,6 +55,7 @@ define(function (require, exports, module) {
|
||||
cachedToken = null, // the token used in the current hinting session
|
||||
matcher = null, // string matcher for hints
|
||||
jsHintsEnabled = true, // preference setting to enable/disable the hint session
|
||||
noHintsOnDot = false, // preference setting to prevent hints on dot
|
||||
ignoreChange; // can ignore next "change" event if true;
|
||||
|
||||
|
||||
@@ -64,6 +65,9 @@ define(function (require, exports, module) {
|
||||
// This preference controls when Tern will time out when trying to understand files
|
||||
PreferencesManager.definePreference("jscodehints.inferenceTimeout", "number", 5000);
|
||||
|
||||
// This preference controls whether to prevent hints from being displayed when dot is typed
|
||||
PreferencesManager.definePreference("jscodehints.noHintsOnDot", "boolean", false);
|
||||
|
||||
// This preference controls whether to create a session and process all JS files or not.
|
||||
PreferencesManager.definePreference("codehint.JSHints", "boolean", true);
|
||||
|
||||
@@ -84,6 +88,10 @@ define(function (require, exports, module) {
|
||||
jsHintsEnabled = _areHintsEnabled();
|
||||
});
|
||||
|
||||
PreferencesManager.on("change", "jscodehints.noHintsOnDot", function () {
|
||||
noHintsOnDot = !!PreferencesManager.get("jscodehints.noHintsOnDot");
|
||||
});
|
||||
|
||||
/**
|
||||
* Sets the configuration, generally for testing/debugging use.
|
||||
* Configuration keys are merged into the current configuration.
|
||||
@@ -426,7 +434,7 @@ define(function (require, exports, module) {
|
||||
* @return {boolean} - can the provider provide hints for this session?
|
||||
*/
|
||||
JSHints.prototype.hasHints = function (editor, key) {
|
||||
if (session && HintUtils.hintableKey(key)) {
|
||||
if (session && HintUtils.hintableKey(key, !noHintsOnDot)) {
|
||||
|
||||
if (isHTMLFile(session.editor.document)) {
|
||||
if (!isInlineScript(session.editor)) {
|
||||
@@ -467,7 +475,7 @@ define(function (require, exports, module) {
|
||||
var cursor = session.getCursor(),
|
||||
token = session.getToken(cursor);
|
||||
|
||||
if (token && HintUtils.hintableKey(key) && HintUtils.hintable(token)) {
|
||||
if (token && HintUtils.hintableKey(key, !noHintsOnDot) && HintUtils.hintable(token)) {
|
||||
var type = session.getType(),
|
||||
query = session.getQuery();
|
||||
|
||||
|
||||
Reference in new issue
Block a user