Bug 1900395 - [devtools] Migrate getEditorFileMode to use the util in the source editor r=devtools-reviewers,nchevobbe

Differential Revision: https://phabricator.services.mozilla.com/D222833
This commit is contained in:
Hubert Boma Manilla 2024-09-23 10:37:28 +00:00
parent 8240380ef3
commit afd8f544e6
2 changed files with 10 additions and 4 deletions

View File

@ -2182,10 +2182,7 @@ function getCM(dbg) {
// Gets the mode used for the file
function getEditorFileMode(dbg) {
if (isCm6Enabled) {
return dbg.win.document.querySelector(".cm-content").dataset.language;
}
return getCM(dbg).getOption("mode").name;
return getCMEditor(dbg).getEditorFileMode();
}
function getCoordsFromPosition(cm, { line, ch }) {

View File

@ -3100,6 +3100,15 @@ class Editor extends EventEmitter {
return cm.setCursor({ line, ch: column });
}
// Used only in tests
getEditorFileMode() {
const cm = editors.get(this);
if (this.config.cm6) {
return cm.contentDOM.dataset.language;
}
return cm.getOption("mode").name;
}
// Used only in tests
getEditorContent() {
const cm = editors.get(this);