Skip to content

Commit 5c51f54

Browse files
committed
Run global events in an operation
Issue #5653
1 parent 2754478 commit 5c51f54

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/edit/global_events.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,14 @@ import { on } from "../util/event.js"
77

88
function forEachCodeMirror(f) {
99
if (!document.getElementsByClassName) return
10-
let byClass = document.getElementsByClassName("CodeMirror")
10+
let byClass = document.getElementsByClassName("CodeMirror"), editors = []
1111
for (let i = 0; i < byClass.length; i++) {
1212
let cm = byClass[i].CodeMirror
13-
if (cm) f(cm)
13+
if (cm) editors.push(cm)
1414
}
15+
if (editors.length) editors[0].operation(() => {
16+
for (let i = 0; i < editors.length; i++) f(editors[i])
17+
})
1518
}
1619

1720
let globalsRegistered = false

0 commit comments

Comments
 (0)