add input event, make doing multiple changes in one turn much faster
This commit is contained in:
parent
2d6f56d8fd
commit
79c0f83e2c
2 changed files with 13 additions and 2 deletions
|
|
@ -171,6 +171,10 @@ var BackgroundTokenizer = function(tokenizer, editor) {
|
||||||
this.running = setTimeout(this.$worker, 700);
|
this.running = setTimeout(this.$worker, 700);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
this.scheduleStart = function() {
|
||||||
|
this.running = setTimeout(this.$worker, 700);
|
||||||
|
}
|
||||||
|
|
||||||
this.$updateOnChange = function(delta) {
|
this.$updateOnChange = function(delta) {
|
||||||
var range = delta.range;
|
var range = delta.range;
|
||||||
var startRow = range.start.row;
|
var startRow = range.start.row;
|
||||||
|
|
@ -191,8 +195,6 @@ var BackgroundTokenizer = function(tokenizer, editor) {
|
||||||
this.currentLine = Math.min(startRow, this.currentLine, this.doc.getLength());
|
this.currentLine = Math.min(startRow, this.currentLine, this.doc.getLength());
|
||||||
|
|
||||||
this.stop();
|
this.stop();
|
||||||
// pretty long delay to prevent the tokenizer from interfering with the user
|
|
||||||
this.running = setTimeout(this.$worker, 700);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -91,6 +91,15 @@ var Editor = function(renderer, session) {
|
||||||
|
|
||||||
this.$initOperationListeners();
|
this.$initOperationListeners();
|
||||||
|
|
||||||
|
this._$emitInputEvent = lang.delayedCall(function() {
|
||||||
|
this._signal("input", {});
|
||||||
|
this.session.bgTokenizer && this.session.bgTokenizer.scheduleStart();
|
||||||
|
}.bind(this));
|
||||||
|
|
||||||
|
this.on("change", function(_, _self) {
|
||||||
|
_self._$emitInputEvent.schedule(31);
|
||||||
|
});
|
||||||
|
|
||||||
this.setSession(session || new EditSession(""));
|
this.setSession(session || new EditSession(""));
|
||||||
config.resetOptions(this);
|
config.resetOptions(this);
|
||||||
config._emit("editor", this);
|
config._emit("editor", this);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue