Merge remote branch 'upstream/master'
This commit is contained in:
commit
dc84eac595
5 changed files with 88 additions and 85 deletions
|
|
@ -1105,6 +1105,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;
|
||||||
|
|
@ -1148,7 +1149,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);
|
||||||
|
|
@ -1203,16 +1204,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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1220,7 +1221,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;
|
||||||
}
|
}
|
||||||
|
|
@ -1246,11 +1247,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);
|
||||||
|
|
@ -1286,7 +1289,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;
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@
|
||||||
* the Initial Developer. All Rights Reserved.
|
* the Initial Developer. All Rights Reserved.
|
||||||
*
|
*
|
||||||
* Contributor(s):
|
* Contributor(s):
|
||||||
* Fabian Jakobs <fabian AT ajax DOT org>
|
* Fabian Jakobs <fabian AT ajax DOT org>
|
||||||
*
|
*
|
||||||
* Alternatively, the contents of this file may be used under the terms of
|
* Alternatively, the contents of this file may be used under the terms of
|
||||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||||
|
|
@ -42,35 +42,35 @@ var TokenIterator = require("ace/token_iterator").TokenIterator;
|
||||||
|
|
||||||
function BracketMatch() {
|
function BracketMatch() {
|
||||||
|
|
||||||
this.findMatchingBracket = function(position) {
|
this.findMatchingBracket = function(position) {
|
||||||
if (position.column == 0) return null;
|
if (position.column == 0) return null;
|
||||||
|
|
||||||
var charBeforeCursor = this.getLine(position.row).charAt(position.column-1);
|
var charBeforeCursor = this.getLine(position.row).charAt(position.column-1);
|
||||||
if (charBeforeCursor == "") return null;
|
if (charBeforeCursor == "") return null;
|
||||||
|
|
||||||
var match = charBeforeCursor.match(/([\(\[\{])|([\)\]\}])/);
|
var match = charBeforeCursor.match(/([\(\[\{])|([\)\]\}])/);
|
||||||
if (!match) {
|
if (!match) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (match[1]) {
|
if (match[1]) {
|
||||||
return this.$findClosingBracket(match[1], position);
|
return this.$findClosingBracket(match[1], position);
|
||||||
} else {
|
} else {
|
||||||
return this.$findOpeningBracket(match[2], position);
|
return this.$findOpeningBracket(match[2], position);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
this.$brackets = {
|
this.$brackets = {
|
||||||
")": "(",
|
")": "(",
|
||||||
"(": ")",
|
"(": ")",
|
||||||
"]": "[",
|
"]": "[",
|
||||||
"[": "]",
|
"[": "]",
|
||||||
"{": "}",
|
"{": "}",
|
||||||
"}": "{"
|
"}": "{"
|
||||||
};
|
};
|
||||||
|
|
||||||
this.$findOpeningBracket = function(bracket, position) {
|
this.$findOpeningBracket = function(bracket, position) {
|
||||||
var openBracket = this.$brackets[bracket];
|
var openBracket = this.$brackets[bracket];
|
||||||
var depth = 1;
|
var depth = 1;
|
||||||
|
|
||||||
var iterator = new TokenIterator(this, position.row, position.column);
|
var iterator = new TokenIterator(this, position.row, position.column);
|
||||||
|
|
@ -91,14 +91,14 @@ function BracketMatch() {
|
||||||
while (vIndex >= 0) {
|
while (vIndex >= 0) {
|
||||||
var char = value.charAt(vIndex);
|
var char = value.charAt(vIndex);
|
||||||
if (char == openBracket) {
|
if (char == openBracket) {
|
||||||
depth -= 1;
|
depth -= 1;
|
||||||
if (depth == 0) {
|
if (depth == 0) {
|
||||||
return {row: iterator.getCurrentTokenRow(),
|
return {row: iterator.getCurrentTokenRow(),
|
||||||
column: vIndex + iterator.getCurrentTokenColumn()};
|
column: vIndex + iterator.getCurrentTokenColumn()};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (char == bracket) {
|
else if (char == bracket) {
|
||||||
depth += 1;
|
depth += 1;
|
||||||
}
|
}
|
||||||
vIndex -= 1;
|
vIndex -= 1;
|
||||||
}
|
}
|
||||||
|
|
@ -115,41 +115,41 @@ function BracketMatch() {
|
||||||
value = token.value;
|
value = token.value;
|
||||||
vIndex = token.value.length - 1;
|
vIndex = token.value.length - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
};
|
};
|
||||||
|
|
||||||
this.$findClosingBracket = function(bracket, position) {
|
this.$findClosingBracket = function(bracket, position) {
|
||||||
var closingBracket = this.$brackets[bracket];
|
var closingBracket = this.$brackets[bracket];
|
||||||
var depth = 1;
|
var depth = 1;
|
||||||
|
|
||||||
var iterator = new TokenIterator(this, position.row, position.column);
|
var iterator = new TokenIterator(this, position.row, position.column);
|
||||||
var token = iterator.getCurrentToken();
|
var token = iterator.getCurrentToken();
|
||||||
if (!token) return null;
|
if (!token) return null;
|
||||||
|
|
||||||
// Create a pattern that matches any token with the same type as token.type.
|
// Create a pattern that matches any token with the same type as token.type.
|
||||||
// Exception: if token.type includes "lparen", then also match "rparen".
|
// Exception: if token.type includes "lparen", then also match "rparen".
|
||||||
var typeRe = new RegExp("(\\.?[" +
|
var typeRe = new RegExp("(\\.?[" +
|
||||||
token.type.replace(".", "|").replace("lparen", "lparen|rparen") + "])+");
|
token.type.replace(".", "|").replace("lparen", "lparen|rparen") + "])+");
|
||||||
|
|
||||||
// Start searching in token, after after the character at position.column
|
// Start searching in token, after after the character at position.column
|
||||||
var vIndex = position.column - iterator.getCurrentTokenColumn();
|
var vIndex = position.column - iterator.getCurrentTokenColumn();
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
|
|
||||||
var value = token.value;
|
var value = token.value;
|
||||||
var valueLength = value.length;
|
var valueLength = value.length;
|
||||||
while (vIndex < valueLength) {
|
while (vIndex < valueLength) {
|
||||||
var char = value.charAt(vIndex);
|
var char = value.charAt(vIndex);
|
||||||
if (char == closingBracket) {
|
if (char == closingBracket) {
|
||||||
depth -= 1;
|
depth -= 1;
|
||||||
if (depth == 0) {
|
if (depth == 0) {
|
||||||
return {row: iterator.getCurrentTokenRow(),
|
return {row: iterator.getCurrentTokenRow(),
|
||||||
column: vIndex + iterator.getCurrentTokenColumn()};
|
column: vIndex + iterator.getCurrentTokenColumn()};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (char == bracket) {
|
else if (char == bracket) {
|
||||||
depth += 1;
|
depth += 1;
|
||||||
}
|
}
|
||||||
vIndex += 1;
|
vIndex += 1;
|
||||||
}
|
}
|
||||||
|
|
@ -162,12 +162,12 @@ function BracketMatch() {
|
||||||
|
|
||||||
if (token == null)
|
if (token == null)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
vIndex = 0;
|
vIndex = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
exports.BracketMatch = BracketMatch;
|
exports.BracketMatch = BracketMatch;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -93,8 +93,8 @@ var vimStates = {
|
||||||
},
|
},
|
||||||
vimcommand("(k|up)", "golineup"),
|
vimcommand("(k|up)", "golineup"),
|
||||||
vimcommand("(j|down)", "golinedown"),
|
vimcommand("(j|down)", "golinedown"),
|
||||||
vimcommand("(l|right)", "golineright"),
|
vimcommand("(l|right)", "gotoright"),
|
||||||
vimcommand("(h|left)", "golineleft"),
|
vimcommand("(h|left)", "gotoleft"),
|
||||||
{
|
{
|
||||||
key: "shift-g",
|
key: "shift-g",
|
||||||
exec: "gotoend"
|
exec: "gotoend"
|
||||||
|
|
|
||||||
|
|
@ -54,7 +54,7 @@ define(function(require, exports, module) {
|
||||||
var keywords = lang.arrayToMap((
|
var keywords = lang.arrayToMap((
|
||||||
"this|throw|then|try|typeof|super|switch|return|break|by)|continue|" +
|
"this|throw|then|try|typeof|super|switch|return|break|by)|continue|" +
|
||||||
"catch|class|in|instanceof|is|isnt|if|else|extends|for|forown|" +
|
"catch|class|in|instanceof|is|isnt|if|else|extends|for|forown|" +
|
||||||
"finally|function|while|when|new|not|delete|debugger|do|loop|of|off|" +
|
"finally|function|while|when|new|no|not|delete|debugger|do|loop|of|off|" +
|
||||||
"or|on|unless|until|and|yes").split("|")
|
"or|on|unless|until|and|yes").split("|")
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@
|
||||||
* the Initial Developer. All Rights Reserved.
|
* the Initial Developer. All Rights Reserved.
|
||||||
*
|
*
|
||||||
* Contributor(s):
|
* Contributor(s):
|
||||||
* Fabian Jakobs <fabian AT ajax DOT org>
|
* Fabian Jakobs <fabian AT ajax DOT org>
|
||||||
*
|
*
|
||||||
* Alternatively, the contents of this file may be used under the terms of
|
* Alternatively, the contents of this file may be used under the terms of
|
||||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||||
|
|
@ -48,10 +48,10 @@ var TokenIterator = function(session, initialRow, initialColumn) {
|
||||||
};
|
};
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
|
|
||||||
this.stepBackward = function() {
|
this.stepBackward = function() {
|
||||||
this.$tokenIndex -= 1;
|
this.$tokenIndex -= 1;
|
||||||
|
|
||||||
while (this.$tokenIndex < 0) {
|
while (this.$tokenIndex < 0) {
|
||||||
this.$row -= 1;
|
this.$row -= 1;
|
||||||
if (this.$row < 0)
|
if (this.$row < 0)
|
||||||
|
|
@ -60,18 +60,18 @@ var TokenIterator = function(session, initialRow, initialColumn) {
|
||||||
this.$rowTokens = this.$session.getTokens(this.$row, this.$row)[0].tokens;
|
this.$rowTokens = this.$session.getTokens(this.$row, this.$row)[0].tokens;
|
||||||
this.$tokenIndex = this.$rowTokens.length - 1;
|
this.$tokenIndex = this.$rowTokens.length - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.$rowTokens[this.$tokenIndex];
|
return this.$rowTokens[this.$tokenIndex];
|
||||||
}
|
}
|
||||||
|
|
||||||
this.stepForward = function() {
|
this.stepForward = function() {
|
||||||
var rowCount = this.$session.getLength();
|
var rowCount = this.$session.getLength();
|
||||||
this.$tokenIndex += 1;
|
this.$tokenIndex += 1;
|
||||||
|
|
||||||
while (this.$tokenIndex >= this.$rowTokens.length) {
|
while (this.$tokenIndex >= this.$rowTokens.length) {
|
||||||
this.$row += 1;
|
this.$row += 1;
|
||||||
if (this.$row >= rowCount)
|
if (this.$row >= rowCount)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
this.$rowTokens = this.$session.getTokens(this.$row, this.$row)[0].tokens;
|
this.$rowTokens = this.$session.getTokens(this.$row, this.$row)[0].tokens;
|
||||||
this.$tokenIndex = 0;
|
this.$tokenIndex = 0;
|
||||||
|
|
@ -104,8 +104,8 @@ var TokenIterator = function(session, initialRow, initialColumn) {
|
||||||
}
|
}
|
||||||
|
|
||||||
return column;
|
return column;
|
||||||
}
|
}
|
||||||
|
|
||||||
}).call(TokenIterator.prototype);
|
}).call(TokenIterator.prototype);
|
||||||
|
|
||||||
exports.TokenIterator = TokenIterator;
|
exports.TokenIterator = TokenIterator;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue