editing at the top of large file is much faster now

This commit is contained in:
Fabian Jakobs 2010-10-01 10:22:12 +02:00
commit 9d18fd46dc
3 changed files with 16 additions and 11 deletions

View file

@ -33,7 +33,8 @@ var BackgroundTokenizer = function(tokenizer) {
processedLines += 1;
if ((processedLines % 5 == 0) && (new Date() - workerStart) > 20) {
self.fireUpdateEvent(startLine, self.currentLine-1);
return setTimeout(self.$worker, 10);
self.running = setTimeout(self.$worker, 30);
return;
}
}
@ -78,10 +79,12 @@ var BackgroundTokenizer = function(tokenizer) {
this.stop();
// pretty long delay to prevent the tokenizer from interfering with the user
this.running = setTimeout(this.$worker, 500);
this.running = setTimeout(this.$worker, 700);
};
this.stop = function() {
if (this.running)
clearTimeout(this.running);
this.running = false;
};

View file

@ -119,18 +119,18 @@ var VirtualRenderer = function(container, theme) {
* Triggers partial update of the text layer
*/
this.updateLines = function(firstRow, lastRow) {
if (!this.$updateLines) {
this.$updateLines = {
if (!this.$changedLines) {
this.$changedLines = {
firstRow: firstRow,
lastRow: lastRow
}
}
else {
if (this.$updateLines.firstRow > firstRow)
this.$updateLines.firstRow = firstRow;
if (this.$changedLines.firstRow > firstRow)
this.$changedLines.firstRow = firstRow;
if (this.$updateLines.lastRow < lastRow)
this.$updateLines.lastRow = lastRow;
if (this.$changedLines.lastRow < lastRow)
this.$changedLines.lastRow = lastRow;
}
this.$loop.schedule(this.CHANGE_LINES);
@ -374,8 +374,9 @@ var VirtualRenderer = function(container, theme) {
};
this.$updateLines = function() {
var firstRow = this.$updateLines.firstRow;
var lastRow = this.$updateLines.lastRow;
var firstRow = this.$changedLines.firstRow;
var lastRow = this.$changedLines.lastRow;
this.$changedLines = null;
var layerConfig = this.layerConfig;

View file

@ -129,6 +129,8 @@ var Text = function(parentEl) {
};
this.scrollLines = function(config) {
var _self = this;
this.$computeTabString();
var oldConfig = this.config;
this.config = config;
@ -151,7 +153,6 @@ var Text = function(parentEl) {
appendTop(appendBottom);
var _self = this;
function appendTop(callback) {
if (config.firstRow < oldConfig.firstRow) {
_self.$renderLinesFragment(config, config.firstRow, oldConfig.firstRow - 1, function(fragment) {