diff --git a/lib/ace/commands/default_commands.js b/lib/ace/commands/default_commands.js index 1340cafa..ecf3617a 100644 --- a/lib/ace/commands/default_commands.js +++ b/lib/ace/commands/default_commands.js @@ -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(); } }]; }); diff --git a/lib/ace/editor.js b/lib/ace/editor.js index e6eac8ef..08429e91 100644 --- a/lib/ace/editor.js +++ b/lib/ace/editor.js @@ -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});