create wrap data lazily
This commit is contained in:
parent
316bb55f17
commit
f4d1dc7c13
1 changed files with 17 additions and 27 deletions
|
|
@ -1556,10 +1556,7 @@ var EditSession = function(text, mode) {
|
||||||
// If wrapMode is activaed, the wrapData array has to be initialized.
|
// If wrapMode is activaed, the wrapData array has to be initialized.
|
||||||
if (useWrapMode) {
|
if (useWrapMode) {
|
||||||
var len = this.getLength();
|
var len = this.getLength();
|
||||||
this.$wrapData = [];
|
this.$wrapData = Array(len);
|
||||||
for (var i = 0; i < len; i++) {
|
|
||||||
this.$wrapData.push([]);
|
|
||||||
}
|
|
||||||
this.$updateWrapData(0, len - 1);
|
this.$updateWrapData(0, len - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1719,16 +1716,10 @@ var EditSession = function(text, mode) {
|
||||||
|
|
||||||
lastRow = firstRow;
|
lastRow = firstRow;
|
||||||
} else {
|
} else {
|
||||||
var args;
|
var args = Array(len);
|
||||||
if (useWrapMode) {
|
|
||||||
args = [firstRow, 0];
|
|
||||||
for (var i = 0; i < len; i++) args.push([]);
|
|
||||||
this.$wrapData.splice.apply(this.$wrapData, args);
|
|
||||||
} else {
|
|
||||||
args = Array(len);
|
|
||||||
args.unshift(firstRow, 0);
|
args.unshift(firstRow, 0);
|
||||||
this.$rowLengthCache.splice.apply(this.$rowLengthCache, args);
|
var arr = useWrapMode ? this.$wrapData : this.$rowLengthCache
|
||||||
}
|
arr.splice.apply(arr, args);
|
||||||
|
|
||||||
// If some new line is added inside of a foldLine, then split
|
// If some new line is added inside of a foldLine, then split
|
||||||
// the fold line up.
|
// the fold line up.
|
||||||
|
|
@ -1833,8 +1824,7 @@ var EditSession = function(text, mode) {
|
||||||
lines[foldLine.end.row].length + 1
|
lines[foldLine.end.row].length + 1
|
||||||
);
|
);
|
||||||
|
|
||||||
wrapData[foldLine.start.row]
|
wrapData[foldLine.start.row] = this.$computeWrapSplits(tokens, wrapLimit, tabSize);
|
||||||
= this.$computeWrapSplits(tokens, wrapLimit, tabSize);
|
|
||||||
row = foldLine.end.row + 1;
|
row = foldLine.end.row + 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -2023,9 +2013,6 @@ var EditSession = function(text, mode) {
|
||||||
* The first position indicates the number of columns for `str` on screen.<br/>
|
* The first position indicates the number of columns for `str` on screen.<br/>
|
||||||
* The second value contains the position of the document column that this function read until.
|
* The second value contains the position of the document column that this function read until.
|
||||||
*
|
*
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
**/
|
**/
|
||||||
this.$getStringScreenWidth = function(str, maxScreenColumn, screenColumn) {
|
this.$getStringScreenWidth = function(str, maxScreenColumn, screenColumn) {
|
||||||
if (maxScreenColumn == 0)
|
if (maxScreenColumn == 0)
|
||||||
|
|
@ -2326,6 +2313,7 @@ var EditSession = function(text, mode) {
|
||||||
// Clamp textLine if in wrapMode.
|
// Clamp textLine if in wrapMode.
|
||||||
if (this.$useWrapMode) {
|
if (this.$useWrapMode) {
|
||||||
var wrapRow = this.$wrapData[foldStartRow];
|
var wrapRow = this.$wrapData[foldStartRow];
|
||||||
|
if (wrapRow) {
|
||||||
var screenRowOffset = 0;
|
var screenRowOffset = 0;
|
||||||
while (textLine.length >= wrapRow[screenRowOffset]) {
|
while (textLine.length >= wrapRow[screenRowOffset]) {
|
||||||
screenRow ++;
|
screenRow ++;
|
||||||
|
|
@ -2335,6 +2323,7 @@ var EditSession = function(text, mode) {
|
||||||
wrapRow[screenRowOffset - 1] || 0, textLine.length
|
wrapRow[screenRowOffset - 1] || 0, textLine.length
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
row: screenRow,
|
row: screenRow,
|
||||||
|
|
@ -2387,7 +2376,8 @@ var EditSession = function(text, mode) {
|
||||||
var foldStart = fold ? fold.start.row :Infinity;
|
var foldStart = fold ? fold.start.row :Infinity;
|
||||||
|
|
||||||
while (row < lastRow) {
|
while (row < lastRow) {
|
||||||
screenRows += this.$wrapData[row].length + 1;
|
var splits = this.$wrapData[row];
|
||||||
|
screenRows += splits ? splits.length + 1 : 1;
|
||||||
row ++;
|
row ++;
|
||||||
if (row > foldStart) {
|
if (row > foldStart) {
|
||||||
row = fold.end.row+1;
|
row = fold.end.row+1;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue