diff --git a/lib/ace/background_tokenizer.js b/lib/ace/background_tokenizer.js index b2ba3733..da8008bd 100644 --- a/lib/ace/background_tokenizer.js +++ b/lib/ace/background_tokenizer.js @@ -36,8 +36,6 @@ var EventEmitter = require("./lib/event_emitter").EventEmitter; /** - * - * * Tokenizes the current [[Document `Document`]] in the background, and caches the tokenized rows for future use. * * If a certain row is changed, everything below that row is re-tokenized. @@ -50,8 +48,6 @@ var EventEmitter = require("./lib/event_emitter").EventEmitter; * @param {Tokenizer} tokenizer The tokenizer to use * @param {Editor} editor The editor to associate with * - * - * * @constructor **/ @@ -89,10 +85,9 @@ var BackgroundTokenizer = function(tokenizer, editor) { // only check every 5 lines processedLines ++; - if ((processedLines % 5 == 0) && (new Date() - workerStart) > 20) { + if ((processedLines % 5 === 0) && (new Date() - workerStart) > 20) { self.running = setTimeout(self.$worker, 20); - self.currentLine = currentLine; - return; + break; } } self.currentLine = currentLine; diff --git a/lib/ace/editor.js b/lib/ace/editor.js index 6a68e5de..83782f06 100644 --- a/lib/ace/editor.js +++ b/lib/ace/editor.js @@ -702,12 +702,13 @@ var Editor = function(renderer, session) { lastRow = range.end.row; else lastRow = Infinity; - this.renderer.updateLines(range.start.row, lastRow); + this.renderer.updateLines(range.start.row, lastRow, this.session.$useWrapMode); this._signal("change", e); // update cursor because tab characters can influence the cursor position this.$cursorChange(); + this.$updateHighlightActiveLine(); }; this.onTokenizerUpdate = function(e) { diff --git a/lib/ace/virtual_renderer.js b/lib/ace/virtual_renderer.js index 33f3a906..d3e26758 100644 --- a/lib/ace/virtual_renderer.js +++ b/lib/ace/virtual_renderer.js @@ -258,7 +258,7 @@ var VirtualRenderer = function(container, theme) { * * **/ - this.updateLines = function(firstRow, lastRow) { + this.updateLines = function(firstRow, lastRow, force) { if (lastRow === undefined) lastRow = Infinity; @@ -276,8 +276,17 @@ var VirtualRenderer = function(container, theme) { this.$changedLines.lastRow = lastRow; } - if (this.$changedLines.firstRow > this.layerConfig.lastRow || - this.$changedLines.lastRow < this.layerConfig.firstRow) + // If the change happened offscreen above us then it's possible + // that a new line wrap will affect the position of the lines on our + // screen so they need redrawn. + // TODO: better solution is to not change scroll position when text is changed outside of visible area + if (this.$changedLines.lastRow < this.layerConfig.firstRow) { + if (force) + this.$changedLines.lastRow = this.layerConfig.lastRow; + else + return; + } + if (this.$changedLines.firstRow > this.layerConfig.lastRow) return; this.$loop.schedule(this.CHANGE_LINES); };