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

Simple code hints preferences to enable/disable individual/all code hints providers. #8272

Merged
merged 3 commits into from
Jul 19, 2014

Conversation

RaymondLim
Copy link
Contributor

This fixes #8173. You can use one or more of the following preferences to turn on/off individual hints provider.
By default, showCodeHints is true and you don't need any of the following preferences to use the existing code hints providers. When you want to disable any of them, just add "codehint.<HINT_PROVIDER_CONSTRUCTOR_NAME>": false in the brackets.json file.

    "codehint.TagHints": false,
    "codehint.AttrHints": true,
    "codehint.CssPropHints": true,
    "codehint.UrlCodeHints": true,
    "codehint.SpecialCharHints": false,
    "codehint.JSHints": true,
    "showCodeHints": true

@hkongm
Copy link

hkongm commented Jul 4, 2014

CSShint:false, it's doesn't work...
even on these:
"codehint.TagHints": false,
"codehint.AttrHints": false,
"codehint.CssPropHints": false,
"codehint.UrlCodeHints": false,
"codehint.SpecialCharHints": false,
"codehint.JSHints": false,
"showCodeHints": false,

@RaymondLim
Copy link
Contributor Author

@hkongm Are you sure you're trying them with my changes and adding them into the correct brackets.json file?

Note that your try of CSShint:false won't work. You need to use the exact string that I listed. ie. codehint. followed by the constructor name of the hint provider.

@hkongm
Copy link

hkongm commented Jul 8, 2014

{
"linting.collapsed": true,
"styleActiveLine": true,
"spaceUnits": 2,
"wordWrap": false,
"theseus.enabled": false,
"closeBrackets": true,
"debug.showErrorsInStatusBar": false,
"quickview.enabled": false,
"brackets-nodejs.node-bin": "/usr/local/bin/node",
"Themes-for-brackets.isCustom": false,
"Themes-for-brackets.theme": "dark-soda",
"codehint.TagHints": false,
"codehint.AttrHints": false,
"codehint.CssPropHints": false,
"codehint.UrlCodeHints": false,
"codehint.SpecialCharHints": false,
"codehint.JSHints": false,
"showCodeHints": false,
"linting.enabled": false
}
this is my brackets.json.

every option does work, but the codehints ...

my plugins list:
brackets dash
code folding
emmet
less auto compile
nodejs bindings
themes for brackets

@RaymondLim
Copy link
Contributor Author

@hkongm I'm still confused with what you're saying. Just having "showCodeHints": false in your brackets.json file will disable all code hints. So which code hint is still active with your brackets.json? You listed "brackets dash" and "code folding" after the line but the codehints.... I'm not sure what you're referring with that list. Got it. You're saying you have those extensions installed, but I don't think any extension will affect code hints preferences.

@RaymondLim
Copy link
Contributor Author

@hkongm I replaced my brackets.json file with yours and I'm still able to disable all code hints on my Win 7. BTW, which OS platform are you using? And also, how do you put my changes into your local build? Are you replacing your local version of src/editor/CodeHintManager.js with the changes in this pull request? Or are you switching to rlim/code-hints-pref branch in your local Brackets repo?

@hkongm
Copy link

hkongm commented Jul 11, 2014

osx 10.9.4
brackets sprint 41

I will abort this issue, after all this is not a big deal.

thanks again, @RaymondLim

@RaymondLim
Copy link
Contributor Author

@hkongm Since you're running sprint 41 build on Mac, you don't have my changes to test. In order to test with my changes, you can read this How to Hack on Brackets to set up your local brackets repo and then switch to my branch (which is not yet landed in master). Or you have to wait for the next release after this pull request is merged.

@redmunds
Copy link
Contributor

Triage Complete.

@redmunds redmunds self-assigned this Jul 15, 2014
@@ -501,6 +518,9 @@ define(function (require, exports, module) {
* @param {Editor} editor
*/
function _startNewSession(editor) {
if (!codeHintsEnabled) {
return;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think this check is necessary since it calls _beginSession().

@redmunds
Copy link
Contributor

After turning off JS Code Hints, I notice that the JavaScriptCodeHints extension still processes files. You should try to prevent files from being processed so this change also helps performance.

@redmunds
Copy link
Contributor

Done with initial review.

@RaymondLim
Copy link
Contributor Author

@redmunds All of your suggestions are taking care of. Ready for re-review.

jsHintsEnabled = PreferencesManager.get("codehint.JSHints");
}
});

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 is not quite right. jsHintsEnabled needs to be recomputed whenever either of the prefs change, right? Also, if pref is not set (i.e. undefined), then default is true (not false). Something like this:

    function areHintsEnabled() {
        return (PreferencesManager.get("codehint.JSHints") !== false) && (PreferencesManager.get("showCodeHints") !== false); 
    }

    PreferencesManager.on("change", "codehint.JSHints", function () {
        jsHintsEnabled = areHintsEnabled();
    });

    PreferencesManager.on("change", "showCodeHints", function () {
        jsHintsEnabled = areHintsEnabled();
    });

Copy link
Contributor

Choose a reason for hiding this comment

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

if pref is not set (i.e. undefined), then default is true (not false).

Both of these prefs have default values, so this statement is not correct, but there is no UI so user needs to manually set values, so it's still a good idea to compare that returned value is !== false.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@redmunds Thanks for the code. You're right that I forgot to consider the cases where either of the prefs is not set.

@redmunds
Copy link
Contributor

Done with review.

@RaymondLim
Copy link
Contributor Author

@redmunds Changes are pushed. Ready for re-review.

@redmunds
Copy link
Contributor

Looks good. Merging.

redmunds added a commit that referenced this pull request Jul 19, 2014
Simple code hints preferences to enable/disable individual/all code hints providers.
@redmunds redmunds merged commit 2ab6dff into master Jul 19, 2014
@redmunds redmunds deleted the rlim/code-hints-pref branch July 19, 2014 16:43
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

how to turn off the css code hinting?
3 participants