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 docColumn = 0;
|
||||
var column;
|
||||
var foldLine;
|
||||
var foldLineRowLength;
|
||||
var row = 0;
|
||||
var rowLength = 0;
|
||||
var splits = null;
|
||||
var split = 0;
|
||||
|
||||
var rowCache = this.$rowCache;
|
||||
var doCache = !rowCache.length;
|
||||
|
|
@ -1406,6 +1404,11 @@ var EditSession = function(text, mode) {
|
|||
}
|
||||
}
|
||||
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) {
|
||||
if (doCache
|
||||
|
|
@ -1417,28 +1420,32 @@ var EditSession = function(text, mode) {
|
|||
docRowCacheLast = docRow;
|
||||
}
|
||||
rowLength = this.getRowLength(docRow);
|
||||
if (row + rowLength - 1 >= screenRow) {
|
||||
if (row + rowLength - 1 >= screenRow || docRow >= maxRow) {
|
||||
break;
|
||||
} else {
|
||||
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
|
||||
var maxRow = this.getLength()-1
|
||||
if(docRow > maxRow)
|
||||
docRow = maxRow;
|
||||
|
||||
foldLine = this.getFoldLine(docRow);
|
||||
line = foldLine
|
||||
? this.getFoldDisplayLine(foldLine)
|
||||
: this.getLine(docRow);
|
||||
if (foldLine && foldLine.start.row <= docRow)
|
||||
line = this.getFoldDisplayLine(foldLine);
|
||||
else {
|
||||
line = this.getLine(docRow);
|
||||
foldLine = null;
|
||||
}
|
||||
|
||||
if (this.$useWrapMode) {
|
||||
splits = this.$wrapData[docRow] || [];
|
||||
docColumn = split = splits[screenRow - row - 1] || 0;
|
||||
line = line.substring(split);
|
||||
splits = this.$wrapData[docRow];
|
||||
if (splits && screenRow > row && splits.length) {
|
||||
docColumn = splits[screenRow - row - 1] || splits[splits.length - 1];
|
||||
line = line.substring(docColumn);
|
||||
}
|
||||
}
|
||||
|
||||
docColumn += this.$getStringScreenWidth(line, screenColumn)[1];
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue