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();
|
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.$mode = null;
|
||||||
this.setMode = function(mode) {
|
this.setMode = function(mode) {
|
||||||
if (this.$mode === mode) return;
|
if (this.$mode === mode) return;
|
||||||
|
|
@ -351,7 +369,7 @@ var EditSession = function(text, mode) {
|
||||||
if (this.$worker)
|
if (this.$worker)
|
||||||
this.$worker.terminate();
|
this.$worker.terminate();
|
||||||
|
|
||||||
if (window.Worker && !require.noWorker)
|
if (this.$useWorker && window.Worker && !require.noWorker)
|
||||||
this.$worker = mode.createWorker(this);
|
this.$worker = mode.createWorker(this);
|
||||||
else
|
else
|
||||||
this.$worker = null;
|
this.$worker = null;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue