workaround for chrome not displaying middle of very long lines
This commit is contained in:
parent
202ecaac90
commit
a23bdb49a2
2 changed files with 17 additions and 5 deletions
|
|
@ -83,6 +83,7 @@ var Tokenizer = function(rules) {
|
||||||
+ (matchcount - 1) + "!=" + rule.token.length);
|
+ (matchcount - 1) + "!=" + rule.token.length);
|
||||||
} else {
|
} else {
|
||||||
rule.tokenArray = rule.token;
|
rule.tokenArray = rule.token;
|
||||||
|
rule.token = null;
|
||||||
rule.onMatch = this.$arrayTokens;
|
rule.onMatch = this.$arrayTokens;
|
||||||
}
|
}
|
||||||
} else if (typeof rule.token == "function" && !rule.onMatch) {
|
} else if (typeof rule.token == "function" && !rule.onMatch) {
|
||||||
|
|
@ -271,7 +272,7 @@ var Tokenizer = function(rules) {
|
||||||
|
|
||||||
if (value) {
|
if (value) {
|
||||||
if (typeof type == "string") {
|
if (typeof type == "string") {
|
||||||
if ((!rule || rule.merge !== false) && token.type === type) {
|
if ((!rule || rule.merge) && token.type === type) {
|
||||||
token.value += value;
|
token.value += value;
|
||||||
} else {
|
} else {
|
||||||
if (token.type)
|
if (token.type)
|
||||||
|
|
@ -293,8 +294,17 @@ var Tokenizer = function(rules) {
|
||||||
lastIndex = index;
|
lastIndex = index;
|
||||||
|
|
||||||
if (tokens.length > MAX_TOKEN_COUNT) {
|
if (tokens.length > MAX_TOKEN_COUNT) {
|
||||||
token.value += line.substr(lastIndex);
|
// chrome doens't show contents of text nodes with very long text
|
||||||
currentState = "start"
|
while (lastIndex < line.length) {
|
||||||
|
if (token.type)
|
||||||
|
tokens.push(token);
|
||||||
|
token = {
|
||||||
|
value: line.substring(lastIndex, lastIndex += 2000),
|
||||||
|
type: "overflow"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
currentState = "start";
|
||||||
|
stack = [];
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,7 @@ define(function(require, exports, module) {
|
||||||
var BaseTokenizer = require("./tokenizer").Tokenizer;
|
var BaseTokenizer = require("./tokenizer").Tokenizer;
|
||||||
|
|
||||||
// tokenizing lines longer than this makes editor very slow
|
// tokenizing lines longer than this makes editor very slow
|
||||||
var MAX_TOKEN_COUNT = 1000;
|
var MAX_TOKEN_COUNT = 100000;
|
||||||
/*
|
/*
|
||||||
* version of Tokenizer with additional logging
|
* version of Tokenizer with additional logging
|
||||||
* and infinite loop checks
|
* and infinite loop checks
|
||||||
|
|
@ -80,7 +80,7 @@ var Tokenizer = function(rules) {
|
||||||
};
|
};
|
||||||
initState();
|
initState();
|
||||||
|
|
||||||
var maxRecur = 10000;
|
var maxRecur = 100000;
|
||||||
|
|
||||||
while (match = re.exec(line)) {
|
while (match = re.exec(line)) {
|
||||||
var type = mapping.defaultToken;
|
var type = mapping.defaultToken;
|
||||||
|
|
@ -177,5 +177,7 @@ var Tokenizer = function(rules) {
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Tokenizer.prototype = BaseTokenizer.prototype;
|
||||||
|
|
||||||
exports.Tokenizer = Tokenizer;
|
exports.Tokenizer = Tokenizer;
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue