add option to turn off workers
This commit is contained in:
parent
f11be2cdb5
commit
527fcff5f5
1 changed files with 19 additions and 1 deletions
|
|
@ -344,6 +344,24 @@ var EditSession = function(text, mode) {
|
|||
return this.doc.getNewLineMode();
|
||||
};
|
||||
|
||||
this.$useWorker = true;
|
||||
this.setUseWorker = function(useWorker) {
|
||||
if (this.$useWorker == useWorker)
|
||||
return;
|
||||
|
||||
if (useWorker && !this.$worker && window.Worker)
|
||||
this.$worker = mode.createWorker(this);
|
||||
|
||||
if (!useWorker && this.$worker) {
|
||||
this.$worker.terminate();
|
||||
this.$worker = null;
|
||||
}
|
||||
};
|
||||
|
||||
this.getUseWorker = function() {
|
||||
return this.$useWorker;
|
||||
};
|
||||
|
||||
this.$mode = null;
|
||||
this.setMode = function(mode) {
|
||||
if (this.$mode === mode) return;
|
||||
|
|
@ -351,7 +369,7 @@ var EditSession = function(text, mode) {
|
|||
if (this.$worker)
|
||||
this.$worker.terminate();
|
||||
|
||||
if (window.Worker && !require.noWorker)
|
||||
if (this.$useWorker && window.Worker && !require.noWorker)
|
||||
this.$worker = mode.createWorker(this);
|
||||
else
|
||||
this.$worker = null;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue