Adobe Brackets - Finding the values of .useTabChar .tabSize and .spaceUnits

StackOverflow https://stackoverflow.com/questions/21364408

  •  02-10-2022
  •  | 
  •  

Вопрос

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); 
Это было полезно?

Решение

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");
});
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top