Provide "go to matching brace" command with shortcut Ctrl+M. #3320

Closed
wants to merge 1 commit into
from

Projects

None yet

4 participants

@RaymondLim

No description provided.

@jasonsanjose
Adobe Systems Incorporated member

Tagging open, but for sprint 25. Please do not merge in sprint 24.

@TomMalbran

I can take this one too :)

@TomMalbran TomMalbran was assigned Apr 20, 2013
@TomMalbran TomMalbran commented on the diff Apr 20, 2013
src/editor/EditorCommandHandlers.js
@@ -785,21 +785,39 @@ define(function (require, exports, module) {
return result.promise();
}
+ /**
+ * Move the cursor to the matching brace if the character before/after is
+ * one of these characters -- ()[]{} --- and a match is found.
+ */
+ function findMatchingBrace() {
+ var editor = EditorManager.getFocusedEditor();
+ if (editor) {
+ var maxLinesToScan = 1500,
@TomMalbran
TomMalbran Apr 20, 2013

This should be defined as a constant.

@TomMalbran TomMalbran commented on the diff Apr 20, 2013
src/nls/root/strings.js
@@ -229,6 +229,7 @@ define({
"CMD_QUICK_OPEN" : "Quick Open",
"CMD_GOTO_LINE" : "Go to Line",
"CMD_GOTO_DEFINITION" : "Go to Definition",
+ "CMD_GOTO_MATCHING_BRACE" : "Go to Matching Brace",
@TomMalbran
TomMalbran Apr 20, 2013

Maybe Jump to Matching Brace might be more appropriate here, since it jumps and doesn't open a dialog like the first 2, and might go better with the new Jump to Definition command, although is also an even longer name. If changed, maybe the key could just be "JUMPTO_BRACE".

@TomMalbran

Initial review complete.

I noticed that when going to the opening brace, it places the cursor before it. It might be better to place it after, so you could just start writing code, instead of moving the cursor first. I checked that Sublime places the cursor after the opening brace and before the closing brace when jumping to the matching brace.

@TomMalbran

@RaymondLim Want to revive this PR or just close it and redo it?

@pthiess
Adobe Systems Incorporated member

@RaymondLim -- closing this one as it is sitting here for a while. Please consider to re-submit as needed.

@pthiess pthiess closed this May 14, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment