revert changes to worker

This commit is contained in:
nightwing 2013-04-12 12:09:15 +04:00
commit dc198344d5
7 changed files with 186 additions and 196 deletions

View file

@ -46,7 +46,6 @@ var Search = require("./search").Search;
var Range = require("./range").Range;
var EventEmitter = require("./lib/event_emitter").EventEmitter;
var CommandManager = require("./commands/command_manager").CommandManager;
var Autocomplete = require("./autocomplete").Autocomplete;
var defaultCommands = require("./commands/default_commands").commands;
var config = require("./config");
@ -90,7 +89,6 @@ var Editor = function(renderer, session) {
});
this.setSession(session || new EditSession(""));
Autocomplete.addTo(this);
config.resetOptions(this);
config._emit("editor", this);
};

View file

@ -7,14 +7,12 @@ var lang = require("../lib/lang");
var Mirror = exports.Mirror = function(sender) {
this.sender = sender;
var doc = this.doc = new Document("");
this.data = {};
var deferredUpdate = this.deferredUpdate = lang.delayedCall(this.onUpdate.bind(this));
var _self = this;
sender.on("change", function(e) {
doc.applyDeltas(e.data);
if (_self.$defer)
deferredUpdate.schedule(_self.$timeout);
});
};
@ -22,19 +20,13 @@ var Mirror = exports.Mirror = function(sender) {
(function() {
this.$timeout = 500;
this.$defer = true;
this.setTimeout = function(timeout) {
this.$timeout = timeout;
};
this.setDeferredUpdate = function(defer) {
this.$defer = defer;
};
this.setValue = function(value, data) {
this.setValue = function(value) {
this.doc.setValue(value);
this.data = data;
this.deferredUpdate.schedule(this.$timeout);
};

View file

@ -144,12 +144,12 @@ var WorkerClient = function(topLevelNamespaces, mod, classname) {
catch(ex) {}
};
this.attachToDocument = function(doc, data, ignore) {
if (this.$doc && !ignore)
this.attachToDocument = function(doc) {
if(this.$doc)
this.terminate();
this.$doc = doc;
this.call("setValue", [doc.getValue(), data]);
this.call("setValue", [doc.getValue()]);
doc.on("change", this.changeListener);
};