revert changes to worker
This commit is contained in:
parent
5c1db2dbcc
commit
dc198344d5
7 changed files with 186 additions and 196 deletions
|
|
@ -46,7 +46,6 @@ var Search = require("./search").Search;
|
||||||
var Range = require("./range").Range;
|
var Range = require("./range").Range;
|
||||||
var EventEmitter = require("./lib/event_emitter").EventEmitter;
|
var EventEmitter = require("./lib/event_emitter").EventEmitter;
|
||||||
var CommandManager = require("./commands/command_manager").CommandManager;
|
var CommandManager = require("./commands/command_manager").CommandManager;
|
||||||
var Autocomplete = require("./autocomplete").Autocomplete;
|
|
||||||
var defaultCommands = require("./commands/default_commands").commands;
|
var defaultCommands = require("./commands/default_commands").commands;
|
||||||
var config = require("./config");
|
var config = require("./config");
|
||||||
|
|
||||||
|
|
@ -90,7 +89,6 @@ var Editor = function(renderer, session) {
|
||||||
});
|
});
|
||||||
|
|
||||||
this.setSession(session || new EditSession(""));
|
this.setSession(session || new EditSession(""));
|
||||||
Autocomplete.addTo(this);
|
|
||||||
config.resetOptions(this);
|
config.resetOptions(this);
|
||||||
config._emit("editor", this);
|
config._emit("editor", this);
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -7,14 +7,12 @@ var lang = require("../lib/lang");
|
||||||
var Mirror = exports.Mirror = function(sender) {
|
var Mirror = exports.Mirror = function(sender) {
|
||||||
this.sender = sender;
|
this.sender = sender;
|
||||||
var doc = this.doc = new Document("");
|
var doc = this.doc = new Document("");
|
||||||
this.data = {};
|
|
||||||
|
|
||||||
var deferredUpdate = this.deferredUpdate = lang.delayedCall(this.onUpdate.bind(this));
|
var deferredUpdate = this.deferredUpdate = lang.delayedCall(this.onUpdate.bind(this));
|
||||||
|
|
||||||
var _self = this;
|
var _self = this;
|
||||||
sender.on("change", function(e) {
|
sender.on("change", function(e) {
|
||||||
doc.applyDeltas(e.data);
|
doc.applyDeltas(e.data);
|
||||||
if (_self.$defer)
|
|
||||||
deferredUpdate.schedule(_self.$timeout);
|
deferredUpdate.schedule(_self.$timeout);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
@ -22,19 +20,13 @@ var Mirror = exports.Mirror = function(sender) {
|
||||||
(function() {
|
(function() {
|
||||||
|
|
||||||
this.$timeout = 500;
|
this.$timeout = 500;
|
||||||
this.$defer = true;
|
|
||||||
|
|
||||||
this.setTimeout = function(timeout) {
|
this.setTimeout = function(timeout) {
|
||||||
this.$timeout = timeout;
|
this.$timeout = timeout;
|
||||||
};
|
};
|
||||||
|
|
||||||
this.setDeferredUpdate = function(defer) {
|
this.setValue = function(value) {
|
||||||
this.$defer = defer;
|
|
||||||
};
|
|
||||||
|
|
||||||
this.setValue = function(value, data) {
|
|
||||||
this.doc.setValue(value);
|
this.doc.setValue(value);
|
||||||
this.data = data;
|
|
||||||
this.deferredUpdate.schedule(this.$timeout);
|
this.deferredUpdate.schedule(this.$timeout);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -144,12 +144,12 @@ var WorkerClient = function(topLevelNamespaces, mod, classname) {
|
||||||
catch(ex) {}
|
catch(ex) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
this.attachToDocument = function(doc, data, ignore) {
|
this.attachToDocument = function(doc) {
|
||||||
if (this.$doc && !ignore)
|
if(this.$doc)
|
||||||
this.terminate();
|
this.terminate();
|
||||||
|
|
||||||
this.$doc = doc;
|
this.$doc = doc;
|
||||||
this.call("setValue", [doc.getValue(), data]);
|
this.call("setValue", [doc.getValue()]);
|
||||||
doc.on("change", this.changeListener);
|
doc.on("change", this.changeListener);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue