Open Bug 2083536 Opened 1 month ago Updated 17 hours ago

Add an option to set the mode while setting the editor text

Categories

(DevTools :: Debugger, task, P2)

task

Tracking

(Not tracked)

ASSIGNED

People

(Reporter: bomsy, Assigned: bomsy, NeedInfo)

References

(Blocks 1 open bug)

Details

Attachments

(1 external file)

Currently the editor mode is set separately from the editor text, even though they are called immediately after each other.

https://searchfox.org/firefox-main/rev/c0ad8e7c1d3d33cf3405f7019994471ac8baf4e7/devtools/client/debugger/src/components/Editor/index.js#744-749

if (selectedSource.isStyleSheet) {
  await editor.setMode(SourceEditor.modes.css);
}
await editor.setText(selectedSourceTextContent.value.value, {
  documentId: selectedSource.id,
});

This means that two separate transactions will be dispatched to update the editor state. The issue is that even though we expect these updates to be made to the same state snapshot, there is no guarantee as intermediate side effects might change the snapshot before the second update, leading to index shifting bugs.
To make sure the same state snapshot is updated, lets combine both into the same transaction. We can do this by allowing to define a mode when setting the editor text.

Assignee: nobody → hmanilla
Status: NEW → ASSIGNED
Severity: -- → S3
Priority: -- → P2
Duplicate of this bug: 2096872
Pushed by hmanilla@mozilla.com: https://github.com/mozilla-firefox/firefox/commit/7e8e8c9eea28 https://hg.mozilla.org/integration/autoland/rev/86e9f804a3a3 [devtools] Set the editor mode while setting the text r=devtools-reviewers,ochameau
Pushed by smolnar@mozilla.com: https://github.com/mozilla-firefox/firefox/commit/4de791e9c62b https://hg.mozilla.org/integration/autoland/rev/5729c00d4cd8 Revert "Bug 2083536 - [devtools] Set the editor mode while setting the text r=devtools-reviewers,ochameau" for causing dt failures @ browser_dbg-editor-mode.js
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: