folds with wrong range shouldn't break renderer
This commit is contained in:
parent
d23ffd89e4
commit
7f8892f9a5
1 changed files with 26 additions and 28 deletions
|
|
@ -510,9 +510,9 @@ var Text = function(parentEl) {
|
|||
};
|
||||
|
||||
this.$renderFoldLine = function(stringBuilder, row, tokens, onlyContents) {
|
||||
var session = this.session,
|
||||
foldLine = session.getFoldLine(row),
|
||||
renderTokens = [];
|
||||
var session = this.session;
|
||||
var foldLine = session.getFoldLine(row);
|
||||
var renderTokens = [];
|
||||
|
||||
function addTokens(tokens, from, to) {
|
||||
var idx = 0, col = 0;
|
||||
|
|
@ -520,16 +520,14 @@ var Text = function(parentEl) {
|
|||
col += tokens[idx].value.length;
|
||||
idx++;
|
||||
|
||||
if (idx == tokens.length) {
|
||||
if (idx == tokens.length)
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (col != from) {
|
||||
var value = tokens[idx].value.substring(from - col);
|
||||
// Check if the token value is longer then the from...to spacing.
|
||||
if (value.length > (to - from)) {
|
||||
if (value.length > (to - from))
|
||||
value = value.substring(0, to - from);
|
||||
}
|
||||
|
||||
renderTokens.push({
|
||||
type: tokens[idx].type,
|
||||
|
|
@ -540,15 +538,15 @@ var Text = function(parentEl) {
|
|||
idx += 1;
|
||||
}
|
||||
|
||||
while (col < to) {
|
||||
while (col < to && idx < tokens.length) {
|
||||
var value = tokens[idx].value;
|
||||
if (value.length + col > to) {
|
||||
value = value.substring(0, to - col);
|
||||
}
|
||||
renderTokens.push({
|
||||
type: tokens[idx].type,
|
||||
value: value
|
||||
});
|
||||
renderTokens.push({
|
||||
type: tokens[idx].type,
|
||||
value: value.substring(0, to - col)
|
||||
});
|
||||
} else
|
||||
renderTokens.push(tokens[idx]);
|
||||
col += value.length;
|
||||
idx += 1;
|
||||
}
|
||||
|
|
@ -556,21 +554,21 @@ var Text = function(parentEl) {
|
|||
|
||||
foldLine.walk(function(placeholder, row, column, lastColumn, isNewRow) {
|
||||
if (placeholder) {
|
||||
renderTokens.push({
|
||||
renderTokens.push({
|
||||
type: "fold",
|
||||
value: placeholder
|
||||
});
|
||||
} else {
|
||||
if (isNewRow)
|
||||
tokens = this.session.getTokens(row);
|
||||
tokens = session.getTokens(row);
|
||||
|
||||
if (tokens.length)
|
||||
addTokens(tokens, lastColumn, column);
|
||||
}
|
||||
}.bind(this), foldLine.end.row, this.session.getLine(foldLine.end.row).length);
|
||||
}, foldLine.end.row, this.session.getLine(foldLine.end.row).length);
|
||||
|
||||
// TODO: Build a fake splits array!
|
||||
var splits = this.session.$useWrapMode?this.session.$wrapData[row]:null;
|
||||
// splits for foldline are stored at its' first row
|
||||
var splits = this.session.$useWrapMode ? this.session.$wrapData[row] : null;
|
||||
this.$renderLineCore(stringBuilder, row, renderTokens, splits, onlyContents);
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue