Skip to content

Commit c576c4c

Browse files
committed
Don't use finally in the operation that initializes the editor
Trying to call endOperation on a half-constructed editor will never end well, and the resulting errors will mask the actual error that happened.
1 parent 0462939 commit c576c4c

File tree

1 file changed

+12
-13
lines changed

1 file changed

+12
-13
lines changed

lib/codemirror.js

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -96,21 +96,20 @@
9696
registerEventHandlers(this);
9797
ensureGlobalHandlers();
9898

99-
var cm = this;
100-
runInOp(this, function() {
101-
cm.curOp.forceUpdate = true;
102-
attachDoc(cm, doc);
99+
startOperation(this);
100+
this.curOp.forceUpdate = true;
101+
attachDoc(this, doc);
103102

104-
if ((options.autofocus && !mobile) || activeElt() == display.input)
105-
setTimeout(bind(onFocus, cm), 20);
106-
else
107-
onBlur(cm);
103+
if ((options.autofocus && !mobile) || activeElt() == display.input)
104+
setTimeout(bind(onFocus, this), 20);
105+
else
106+
onBlur(this);
108107

109-
for (var opt in optionHandlers) if (optionHandlers.hasOwnProperty(opt))
110-
optionHandlers[opt](cm, options[opt], Init);
111-
maybeUpdateLineNumberWidth(cm);
112-
for (var i = 0; i < initHooks.length; ++i) initHooks[i](cm);
113-
});
108+
for (var opt in optionHandlers) if (optionHandlers.hasOwnProperty(opt))
109+
optionHandlers[opt](this, options[opt], Init);
110+
maybeUpdateLineNumberWidth(this);
111+
for (var i = 0; i < initHooks.length; ++i) initHooks[i](this);
112+
endOperation(this);
114113
}
115114

116115
// DISPLAY CONSTRUCTOR

0 commit comments

Comments
 (0)