faster screenToDocumentPosition, and right clamping for wrapped mode
This commit is contained in:
parent
02f8faee55
commit
03a88d3fcf
1 changed files with 23 additions and 16 deletions
|
|
@ -1389,12 +1389,10 @@ var EditSession = function(text, mode) {
|
||||||
var docRow = 0;
|
var docRow = 0;
|
||||||
var docColumn = 0;
|
var docColumn = 0;
|
||||||
var column;
|
var column;
|
||||||
var foldLine;
|
|
||||||
var foldLineRowLength;
|
var foldLineRowLength;
|
||||||
var row = 0;
|
var row = 0;
|
||||||
var rowLength = 0;
|
var rowLength = 0;
|
||||||
var splits = null;
|
var splits = null;
|
||||||
var split = 0;
|
|
||||||
|
|
||||||
var rowCache = this.$rowCache;
|
var rowCache = this.$rowCache;
|
||||||
var doCache = !rowCache.length;
|
var doCache = !rowCache.length;
|
||||||
|
|
@ -1406,6 +1404,11 @@ var EditSession = function(text, mode) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var docRowCacheLast = docRow;
|
var docRowCacheLast = docRow;
|
||||||
|
// clamp row before clamping column, for selection on last line
|
||||||
|
var maxRow = this.getLength() - 1;
|
||||||
|
|
||||||
|
var foldLine = this.getNextFold(docRow);
|
||||||
|
var foldStart = foldLine ?foldLine.start.row :Infinity;
|
||||||
|
|
||||||
while (row <= screenRow) {
|
while (row <= screenRow) {
|
||||||
if (doCache
|
if (doCache
|
||||||
|
|
@ -1417,28 +1420,32 @@ var EditSession = function(text, mode) {
|
||||||
docRowCacheLast = docRow;
|
docRowCacheLast = docRow;
|
||||||
}
|
}
|
||||||
rowLength = this.getRowLength(docRow);
|
rowLength = this.getRowLength(docRow);
|
||||||
if (row + rowLength - 1 >= screenRow) {
|
if (row + rowLength - 1 >= screenRow || docRow >= maxRow) {
|
||||||
break;
|
break;
|
||||||
} else {
|
} else {
|
||||||
row += rowLength;
|
row += rowLength;
|
||||||
docRow = this.getRowFoldEnd(docRow) + 1;
|
docRow++;
|
||||||
|
if(docRow > foldStart) {
|
||||||
|
docRow = foldLine.end.row+1;
|
||||||
|
foldLine = this.getNextFold(docRow);
|
||||||
|
foldStart = foldLine ?foldLine.start.row :Infinity;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// clamp row before clamping column, for selection on last line
|
if (foldLine && foldLine.start.row <= docRow)
|
||||||
var maxRow = this.getLength()-1
|
line = this.getFoldDisplayLine(foldLine);
|
||||||
if(docRow > maxRow)
|
else {
|
||||||
docRow = maxRow;
|
line = this.getLine(docRow);
|
||||||
|
foldLine = null;
|
||||||
foldLine = this.getFoldLine(docRow);
|
}
|
||||||
line = foldLine
|
|
||||||
? this.getFoldDisplayLine(foldLine)
|
|
||||||
: this.getLine(docRow);
|
|
||||||
|
|
||||||
if (this.$useWrapMode) {
|
if (this.$useWrapMode) {
|
||||||
splits = this.$wrapData[docRow] || [];
|
splits = this.$wrapData[docRow];
|
||||||
docColumn = split = splits[screenRow - row - 1] || 0;
|
if (splits && screenRow > row && splits.length) {
|
||||||
line = line.substring(split);
|
docColumn = splits[screenRow - row - 1] || splits[splits.length - 1];
|
||||||
|
line = line.substring(docColumn);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
docColumn += this.$getStringScreenWidth(line, screenColumn)[1];
|
docColumn += this.$getStringScreenWidth(line, screenColumn)[1];
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue