tweak the tokenizer and always chache tokenized rows

to maintain the start state
This commit is contained in:
Fabian Jakobs 2010-09-20 19:39:51 +02:00
commit ad6697719e

View file

@ -23,7 +23,7 @@ var BackgroundTokenizer = function(tokenizer) {
// only check every 5 lines // only check every 5 lines
processedLines += 1; processedLines += 1;
if ((processedLines % 5 == 0) && (new Date() - workerStart) > 30) { 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); return setTimeout(self.$worker, 10);
} }
@ -69,7 +69,7 @@ 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, 200); this.running = setTimeout(this.$worker, 500);
}; };
this.stop = function() { this.stop = function() {
@ -91,11 +91,7 @@ var BackgroundTokenizer = function(tokenizer) {
state = this.lines[row - 1].state; state = this.lines[row - 1].state;
} }
var tokens = this.tokenizer.getLineTokens(this.textLines[row] || "", state || "start"); var tokens = this.tokenizer.getLineTokens(this.textLines[row] || "", state || "start");
if (state) { this.lines[row] = tokens;
this.lines[row] = tokens;
} else {
return tokens;
}
} }
return this.lines[row]; return this.lines[row];
}; };