Question

I can't figure out how to access these values found in Editor.js. I've seen them elsewhere as .getUseTabChar(), .getTabSize(), and .getSpaceUnits()

My extension would benefit being able to get that kind of information. Right now I can find this information with _codeMirror , but from what i've read and seen in Brackathon talks this is considered deprecated.

var editor = EditorManager.getActiveEditor();
console.log(editor._codeMirror.options.indentUnit);
console.log(editor._codeMirror.options.indentWithTabs); 
Was it helpful?

Solution

Brackets Sprint 36 (which is within the next few days, as I write this), includes a new preferences manager. There's a section about this on the wiki. You should be able to do something like this:

var PreferencesManager = brackets.getModule("preferences/PreferencesManager");

// Whenever you need the current value
PreferencesManager.get("spaceUnits");

// If you need to know when the value might have changed:
PreferencesManager.getPreference("spaceUnits").on("change", function () {
    var newValue = PreferencesManager.get("spaceUnits");
});
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top