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; processedLines += 1;
if ((processedLines % 5 == 0) && (new Date() - workerStart) > 20) { if ((processedLines % 5 == 0) && (new Date() - workerStart) > 20) {
self.fireUpdateEvent(startLine, self.currentLine-1); 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(); this.stop();
// pretty long delay to prevent the tokenizer from interfering with the user // 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() { this.stop = function() {
if (this.running)
clearTimeout(this.running);
this.running = false; this.running = false;
}; };

View file

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

View file

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