faster documentToScreenPosition
This commit is contained in:
parent
f86b91463e
commit
4787744645
3 changed files with 22 additions and 21 deletions
|
|
@ -1503,7 +1503,6 @@ var EditSession = function(text, mode) {
|
|||
}
|
||||
|
||||
var wrapData;
|
||||
|
||||
// Special case in wrapMode if the doc is at the end of the document.
|
||||
if (this.$useWrapMode) {
|
||||
wrapData = this.$wrapData;
|
||||
|
|
@ -1517,13 +1516,10 @@ var EditSession = function(text, mode) {
|
|||
}
|
||||
}
|
||||
|
||||
var screenRow = 0,
|
||||
screenColumn = 0,
|
||||
foldStartRow = null,
|
||||
fold = null,
|
||||
folds,
|
||||
comp,
|
||||
foldLine = null;
|
||||
var screenRow = 0;
|
||||
var screenColumn = 0;
|
||||
var foldStartRow = null;
|
||||
var fold = null;
|
||||
|
||||
// Clamp the docRow position in case it's inside of a folded block.
|
||||
fold = this.getFoldAt(docRow, docColumn, 1);
|
||||
|
|
@ -1545,7 +1541,19 @@ var EditSession = function(text, mode) {
|
|||
}
|
||||
var docRowCacheLast = row;
|
||||
|
||||
var foldLine = this.getNextFold(row);
|
||||
var foldStart = foldLine ?foldLine.start.row :Infinity;
|
||||
|
||||
while (row < docRow) {
|
||||
if (row >= foldStart) {
|
||||
rowEnd = foldLine.end.row + 1;
|
||||
if (rowEnd > docRow)
|
||||
break;
|
||||
foldLine = this.getNextFold(rowEnd);
|
||||
foldStart = foldLine ?foldLine.start.row :Infinity;
|
||||
} else {
|
||||
rowEnd = row + 1;
|
||||
}
|
||||
if (doCache
|
||||
&& row - docRowCacheLast > this.$rowCacheSize) {
|
||||
rowCache.push({
|
||||
|
|
@ -1555,26 +1563,20 @@ var EditSession = function(text, mode) {
|
|||
docRowCacheLast = row;
|
||||
}
|
||||
|
||||
rowEnd = this.getRowFoldEnd(row);
|
||||
if (rowEnd >= docRow) {
|
||||
break;
|
||||
}
|
||||
screenRow += this.getRowLength(row);
|
||||
row = rowEnd + 1;
|
||||
row = rowEnd;
|
||||
}
|
||||
|
||||
// Calculate the text line that is displayed in docRow on the screen.
|
||||
var textLine = "";
|
||||
foldLine = this.getFoldLine(docRow);
|
||||
// Check if the final row we want to reach is inside of a fold.
|
||||
if (!foldLine) {
|
||||
textLine = this.getLine(docRow).substring(0, docColumn);
|
||||
foldStartRow = docRow;
|
||||
} else {
|
||||
if (foldLine && row >= foldStart) {
|
||||
textLine = this.getFoldDisplayLine(foldLine, docRow, docColumn);
|
||||
foldStartRow = foldLine.start.row;
|
||||
} else {
|
||||
textLine = this.getLine(docRow).substring(0, docColumn);
|
||||
foldStartRow = docRow;
|
||||
}
|
||||
|
||||
// Clamp textLine if in wrapMode.
|
||||
if (this.$useWrapMode) {
|
||||
var wrapRow = wrapData[foldStartRow];
|
||||
|
|
|
|||
|
|
@ -489,7 +489,6 @@ function Folding() {
|
|||
};
|
||||
|
||||
this.getRowFoldEnd = function(docRow, startFoldRow) {
|
||||
//console.trace()
|
||||
var foldLine = this.getFoldLine(docRow, startFoldRow);
|
||||
return (foldLine
|
||||
? foldLine.end.row
|
||||
|
|
|
|||
|
|
@ -513,7 +513,7 @@ var Text = function(parentEl) {
|
|||
}.bind(this), foldLine.end.row, this.session.getLine(foldLine.end.row).length);
|
||||
|
||||
// TODO: Build a fake splits array!
|
||||
var splits = this.session.$wrapData[row];
|
||||
var splits = this.session.$useWrapMode?this.session.$wrapData[row]:null;
|
||||
this.$renderLineCore(stringBuilder, row, renderTokens, splits);
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue