Skip to content

Commit

Permalink
Run global events in an operation
Browse files Browse the repository at this point in the history
Issue #5653
  • Loading branch information
marijnh committed Nov 20, 2018
1 parent 2754478 commit 5c51f54
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/edit/global_events.js
Expand Up @@ -7,11 +7,14 @@ import { on } from "../util/event.js"

function forEachCodeMirror(f) {
if (!document.getElementsByClassName) return
let byClass = document.getElementsByClassName("CodeMirror")
let byClass = document.getElementsByClassName("CodeMirror"), editors = []
for (let i = 0; i < byClass.length; i++) {
let cm = byClass[i].CodeMirror
if (cm) f(cm)
if (cm) editors.push(cm)
}
if (editors.length) editors[0].operation(() => {
for (let i = 0; i < editors.length; i++) f(editors[i])
})
}

let globalsRegistered = false
Expand Down

0 comments on commit 5c51f54

Please sign in to comment.