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