Closed Bug 2032758 Opened 1 month ago Closed 1 month ago

SourceEditor PREF_CMNEXT_ENABLED should be tool specific

Categories

(DevTools :: Source Editor, defect)

defect

Tracking

(firefox152 fixed)

RESOLVED FIXED
152 Branch
Tracking Status
firefox152 --- fixed

People

(Reporter: nchevobbe, Assigned: bomsy)

References

(Blocks 1 open bug)

Details

Attachments

(1 file, 1 obsolete file)

If devtools.webconsole.codemirrorNext is set to true, if I open the Inspector and click on a stylesheet location, nothing happens, and I'm seeing the following error in the browser toolbox:

TypeError: sourceEditor.setSelection is not a function
    load resource://devtools/client/styleeditor/StyleSheetEditor.sys.mjs:541
    showSummaryEditor resource://devtools/client/styleeditor/StyleEditorUI.sys.mjs:1813
    setActiveSummary resource://devtools/client/styleeditor/StyleEditorUI.sys.mjs:1793
    summaryPromise resource://devtools/client/styleeditor/StyleEditorUI.sys.mjs:1156
    promise callback*#selectEditor resource://devtools/client/styleeditor/StyleEditorUI.sys.mjs:1151
    #sourceLoaded resource://devtools/client/styleeditor/StyleEditorUI.sys.mjs:1065
    #addStyleSheetEditor resource://devtools/client/styleeditor/StyleEditorUI.sys.mjs:750
    promise resource://devtools/client/styleeditor/StyleEditorUI.sys.mjs:576
    #addStyleSheet resource://devtools/client/styleeditor/StyleEditorUI.sys.mjs:577
    #handleStyleSheetResource resource://devtools/client/styleeditor/StyleEditorUI.sys.mjs:1637
    initialize resource://devtools/client/styleeditor/StyleEditorUI.sys.mjs:194
    open resource://devtools/client/styleeditor/panel.js:48
    onLoad resource://devtools/client/framework/toolbox.js:2866

That's because in the source editor, we check devtools.webconsole.codemirrorNext to see if cm6 should be enabled https://searchfox.org/firefox-main/rev/0ae2fcae6a70566ab9e13e401480387b34911bad/devtools/client/shared/sourceeditor/editor.js#105

const PREF_CMNEXT_ENABLED = "devtools.webconsole.codemirrorNext";

and https://searchfox.org/firefox-main/rev/0ae2fcae6a70566ab9e13e401480387b34911bad/devtools/client/shared/sourceeditor/editor.js#4198-4207

// Since Editor is a thin layer over CodeMirror some methods
// are mapped directly—without any changes.
if (!Services.prefs.getBoolPref(PREF_CMNEXT_ENABLED)) {
  CM_MAPPING.forEach(name => {
    Editor.prototype[name] = function (...args) {
      const cm = editors.get(this);
      return cm[name].apply(cm, args);
    };
  });
}

so here, when opening the Style Editor, we'll miss those mapping, but the Style Editor is only working with cm5, so that's causing problems.
We should rather try to use this.config.cm6 to apply those mapping

Thanks for catching!

Flags: needinfo?(hmanilla)
Assignee: nobody → hmanilla
Status: NEW → ASSIGNED

These mapped CM5 methods should not be called for CM6, but lets add a check to makes sure we do not attempt to lookup on the CM6 codemirror instance.

Attachment #9571462 - Attachment description: Bug 2032758 - [devtools] Do not check mapped CM5 methods for CM6 r=#devtools These mapped CM5 methods should not be called for CM6, but lets add a check to makes sure we do not attempt to lookup on the CM6 codemirror instance. → Bug 2032758 - [devtools] Do not check mapped CM5 methods for CM6 r=#devtools
Attachment #9571463 - Attachment is obsolete: true
Pushed by hmanilla@mozilla.com: https://github.com/mozilla-firefox/firefox/commit/5b3f4c5da0e8 https://hg.mozilla.org/integration/autoland/rev/b9d4f6b7021e [devtools] Do not check mapped CM5 methods for CM6 r=devtools-reviewers,nchevobbe
Flags: needinfo?(hmanilla)
Status: ASSIGNED → RESOLVED
Closed: 1 month ago
Resolution: --- → FIXED
Target Milestone: --- → 152 Branch
QA Whiteboard: [qa-triage-done-c153/b152]
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: