fix infinite loop in computeWrapSplits

This commit is contained in:
nightwing 2011-10-30 22:49:02 +04:00
commit 7ad4734e24
2 changed files with 8 additions and 2 deletions

View file

@ -1301,10 +1301,11 @@ var EditSession = function(text, mode) {
while (split > minSplit && tokens[split] < PLACEHOLDER_START) {
split --;
}
while (split > minSplit && tokens[split] == PUNCTUATION) {
split --;
}
// If we found one, then add the split.
if (split > minSplit) {
while(split > minSplit && tokens[split] == PUNCTUATION)
split --;
addSplit(++split);
continue;
}

View file

@ -346,6 +346,11 @@ module.exports = {
computeAndAssert(" ぁぁ", [1, 2], 2);
computeAndAssert(" ぁ\tぁ", [1, 3], 2);
computeAndAssert(" ぁぁ\tぁ", [1, 4], 4);
// Test wrapping for punctuation.
computeAndAssert(" ab.c;ef++", [1, 3, 5, 7, 8], 2);
computeAndAssert(" a.b", [1, 2, 3], 1);
computeAndAssert("#>>", [1, 2], 1);
},
"test get longest line" : function() {