add jump to matching brace command
This commit is contained in:
parent
d2a783f824
commit
3e88268332
2 changed files with 22 additions and 1 deletions
|
|
@ -380,6 +380,10 @@ exports.commands = [{
|
|||
name: "tolowercase",
|
||||
bindKey: bindKey("Ctrl-Shift-U", "Ctrl-Shift-U"),
|
||||
exec: function(editor) { editor.toLowerCase(); }
|
||||
}, {
|
||||
name: "jumptomatching",
|
||||
bindKey: bindKey("Ctrl-Shift-P", "Ctrl-Shift-P"),
|
||||
exec: function(editor) { editor.jumpToMatching(); }
|
||||
}];
|
||||
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1005,7 +1005,24 @@ var Editor = function(renderer, session) {
|
|||
this.selection.moveCursorToPosition(pos);
|
||||
};
|
||||
|
||||
|
||||
this.jumpToMatching = function() {
|
||||
var cursor = this.getCursorPosition();
|
||||
var pos = this.session.findMatchingBracket(cursor);
|
||||
if (!pos) {
|
||||
cursor.column += 1;
|
||||
pos = this.session.findMatchingBracket(cursor);
|
||||
}
|
||||
if (!pos) {
|
||||
cursor.column -= 2;
|
||||
pos = this.session.findMatchingBracket(cursor);
|
||||
}
|
||||
|
||||
if (pos) {
|
||||
this.clearSelection();
|
||||
this.moveCursorTo(pos.row, pos.column);
|
||||
}
|
||||
};
|
||||
|
||||
this.gotoLine = function(lineNumber, column) {
|
||||
this.selection.clearSelection();
|
||||
this.session.unfold({row: lineNumber - 1, column: column || 0});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue