Merge branch 'missing-redraw'

This commit is contained in:
nightwing 2014-08-01 22:07:25 +04:00
commit ec6ffec1e4
3 changed files with 16 additions and 11 deletions

View file

@ -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. * 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. * 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 {Tokenizer} tokenizer The tokenizer to use
* @param {Editor} editor The editor to associate with * @param {Editor} editor The editor to associate with
* *
*
*
* @constructor * @constructor
**/ **/
@ -89,10 +85,9 @@ var BackgroundTokenizer = function(tokenizer, editor) {
// only check every 5 lines // only check every 5 lines
processedLines ++; processedLines ++;
if ((processedLines % 5 == 0) && (new Date() - workerStart) > 20) { if ((processedLines % 5 === 0) && (new Date() - workerStart) > 20) {
self.running = setTimeout(self.$worker, 20); self.running = setTimeout(self.$worker, 20);
self.currentLine = currentLine; break;
return;
} }
} }
self.currentLine = currentLine; self.currentLine = currentLine;

View file

@ -702,12 +702,13 @@ var Editor = function(renderer, session) {
lastRow = range.end.row; lastRow = range.end.row;
else else
lastRow = Infinity; lastRow = Infinity;
this.renderer.updateLines(range.start.row, lastRow); this.renderer.updateLines(range.start.row, lastRow, this.session.$useWrapMode);
this._signal("change", e); this._signal("change", e);
// update cursor because tab characters can influence the cursor position // update cursor because tab characters can influence the cursor position
this.$cursorChange(); this.$cursorChange();
this.$updateHighlightActiveLine();
}; };
this.onTokenizerUpdate = function(e) { this.onTokenizerUpdate = function(e) {

View file

@ -258,7 +258,7 @@ var VirtualRenderer = function(container, theme) {
* *
* *
**/ **/
this.updateLines = function(firstRow, lastRow) { this.updateLines = function(firstRow, lastRow, force) {
if (lastRow === undefined) if (lastRow === undefined)
lastRow = Infinity; lastRow = Infinity;
@ -276,8 +276,17 @@ var VirtualRenderer = function(container, theme) {
this.$changedLines.lastRow = lastRow; this.$changedLines.lastRow = lastRow;
} }
if (this.$changedLines.firstRow > this.layerConfig.lastRow || // If the change happened offscreen above us then it's possible
this.$changedLines.lastRow < this.layerConfig.firstRow) // 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; return;
this.$loop.schedule(this.CHANGE_LINES); this.$loop.schedule(this.CHANGE_LINES);
}; };