This commit is contained in:
parent
f40fa383b2
commit
2b25f3b081
1 changed files with 10 additions and 6 deletions
|
@ -81,7 +81,7 @@ export default function SenseEditor($el) {
|
|||
|
||||
// dirty check for tokenizer state, uses a lot less cycles
|
||||
// than listening for tokenizerUpdate
|
||||
const onceDoneTokenizing = function (func, cancelAlreadyScheduledCalls) {
|
||||
const onceDoneTokenizing = function (callback, cancelAlreadyScheduledCalls) {
|
||||
const session = editor.getSession();
|
||||
let timer = false;
|
||||
const checkInterval = 25;
|
||||
|
@ -95,11 +95,15 @@ export default function SenseEditor($el) {
|
|||
}
|
||||
|
||||
setTimeout(function check() {
|
||||
if (session.bgTokenizer.running) {
|
||||
timer = setTimeout(check, checkInterval);
|
||||
}
|
||||
else {
|
||||
func.apply(self, args);
|
||||
// If the bgTokenizer doesn't exist, we can assume that the underlying editor has been
|
||||
// torn down, e.g. by closing the History tab, and we don't need to do anything further.
|
||||
if (session.bgTokenizer) {
|
||||
// Wait until the bgTokenizer is done running before executing the callback.
|
||||
if (session.bgTokenizer.running) {
|
||||
timer = setTimeout(check, checkInterval);
|
||||
} else {
|
||||
callback.apply(self, args);
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue