From 9d18fd46dce555abb1aea705f8bb4feff1ab0b9b Mon Sep 17 00:00:00 2001 From: Fabian Jakobs Date: Fri, 1 Oct 2010 10:22:12 +0200 Subject: [PATCH] editing at the top of large file is much faster now --- src/ace/BackgroundTokenizer.js | 7 +++++-- src/ace/VirtualRenderer.js | 17 +++++++++-------- src/ace/layer/Text.js | 3 ++- 3 files changed, 16 insertions(+), 11 deletions(-) diff --git a/src/ace/BackgroundTokenizer.js b/src/ace/BackgroundTokenizer.js index 0905f3bd..72d20db3 100644 --- a/src/ace/BackgroundTokenizer.js +++ b/src/ace/BackgroundTokenizer.js @@ -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; }; diff --git a/src/ace/VirtualRenderer.js b/src/ace/VirtualRenderer.js index 4f218786..daf86c12 100644 --- a/src/ace/VirtualRenderer.js +++ b/src/ace/VirtualRenderer.js @@ -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; diff --git a/src/ace/layer/Text.js b/src/ace/layer/Text.js index 37f9aa7e..870ad679 100644 --- a/src/ace/layer/Text.js +++ b/src/ace/layer/Text.js @@ -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) {