Merge pull request #479 from nightwing/pullreq
make wrapping friendlier to code:
This commit is contained in:
commit
e8914acd7b
1 changed files with 16 additions and 13 deletions
|
|
@ -1197,6 +1197,7 @@ var EditSession = function(text, mode) {
|
||||||
CHAR_EXT = 2,
|
CHAR_EXT = 2,
|
||||||
PLACEHOLDER_START = 3,
|
PLACEHOLDER_START = 3,
|
||||||
PLACEHOLDER_BODY = 4,
|
PLACEHOLDER_BODY = 4,
|
||||||
|
PUNCTUATION = 9,
|
||||||
SPACE = 10,
|
SPACE = 10,
|
||||||
TAB = 11,
|
TAB = 11,
|
||||||
TAB_SPACE = 12;
|
TAB_SPACE = 12;
|
||||||
|
|
@ -1240,7 +1241,7 @@ var EditSession = function(text, mode) {
|
||||||
// a split is simple.
|
// a split is simple.
|
||||||
if (tokens[split] >= SPACE) {
|
if (tokens[split] >= SPACE) {
|
||||||
// Include all following spaces + tabs in this split as well.
|
// Include all following spaces + tabs in this split as well.
|
||||||
while (tokens[split] >= SPACE) {
|
while (tokens[split] >= SPACE) {
|
||||||
split ++;
|
split ++;
|
||||||
}
|
}
|
||||||
addSplit(split);
|
addSplit(split);
|
||||||
|
|
@ -1295,16 +1296,16 @@ var EditSession = function(text, mode) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// === ELSE ===
|
// === ELSE ===
|
||||||
// Search for the first non space/tab/placeholder token backwards.
|
// Search for the first non space/tab/placeholder/punctuation token backwards.
|
||||||
for (split; split != lastSplit - 1; split--) {
|
var minSplit = Math.max(split - 10, lastSplit - 1);
|
||||||
if (tokens[split] >= PLACEHOLDER_START) {
|
while (split > minSplit && tokens[split] < PLACEHOLDER_START) {
|
||||||
split++;
|
split --;
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
// If we found one, then add the split.
|
// If we found one, then add the split.
|
||||||
if (split > lastSplit) {
|
if (split > minSplit) {
|
||||||
addSplit(split);
|
while(split > minSplit && tokens[split] == PUNCTUATION)
|
||||||
|
split --;
|
||||||
|
addSplit(++split);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1312,7 +1313,7 @@ var EditSession = function(text, mode) {
|
||||||
split = lastSplit + wrapLimit;
|
split = lastSplit + wrapLimit;
|
||||||
// The split is inside of a CHAR or CHAR_EXT token and no space
|
// The split is inside of a CHAR or CHAR_EXT token and no space
|
||||||
// around -> force a split.
|
// around -> force a split.
|
||||||
addSplit(lastSplit + wrapLimit);
|
addSplit(split);
|
||||||
}
|
}
|
||||||
return splits;
|
return splits;
|
||||||
}
|
}
|
||||||
|
|
@ -1338,11 +1339,13 @@ var EditSession = function(text, mode) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Space
|
// Space
|
||||||
else if(c == 32) {
|
else if (c == 32) {
|
||||||
arr.push(SPACE);
|
arr.push(SPACE);
|
||||||
|
} else if((c > 39 && c < 48) || (c > 57 && c < 64)) {
|
||||||
|
arr.push(PUNCTUATION);
|
||||||
}
|
}
|
||||||
// full width characters
|
// full width characters
|
||||||
else if (isFullWidth(c)) {
|
else if (c >= 0x1100 && isFullWidth(c)) {
|
||||||
arr.push(CHAR, CHAR_EXT);
|
arr.push(CHAR, CHAR_EXT);
|
||||||
} else {
|
} else {
|
||||||
arr.push(CHAR);
|
arr.push(CHAR);
|
||||||
|
|
@ -1378,7 +1381,7 @@ var EditSession = function(text, mode) {
|
||||||
screenColumn += this.getScreenTabSize(screenColumn);
|
screenColumn += this.getScreenTabSize(screenColumn);
|
||||||
}
|
}
|
||||||
// full width characters
|
// full width characters
|
||||||
else if (isFullWidth(c)) {
|
else if (c >= 0x1100 && isFullWidth(c)) {
|
||||||
screenColumn += 2;
|
screenColumn += 2;
|
||||||
} else {
|
} else {
|
||||||
screenColumn += 1;
|
screenColumn += 1;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue