Bug 112138

Summary: Web Inspector: [CodeMirror] add smart braces functionality
Product: WebKit Reporter: Andrey Lushnikov <lushnikov>
Component: Web Inspector (Deprecated)Assignee: Andrey Lushnikov <lushnikov>
Status: RESOLVED FIXED    
Severity: Normal CC: apavlov, keishi, loislo, pfeldman, pmuellr, vsevik, web-inspector-bugs, webkit.review.bot, yurys
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: All   
OS: All   
Attachments:
Description Flags
Patch
none
Patch
none
Patch none

Description Andrey Lushnikov 2013-03-12 05:28:14 PDT
Add smart braces functionality for CodeMirror:
- When a "(" typed, a pair of "()" should be inserted
- When a ")" is typed and cursor is before a closing matched ")", nothing should be inserted, but the cursor should skip the brace
- When a backspace is hit between brace pair "(|)", both braces should be deleted.

Same should work for curly braces.
Comment 1 Andrey Lushnikov 2013-03-12 05:31:55 PDT
Created attachment 192717 [details]
Patch
Comment 2 Andrey Lushnikov 2013-03-12 05:47:45 PDT
Comment on attachment 192717 [details]
Patch

Looks like there's a better way to do this.
Comment 3 Andrey Lushnikov 2013-03-12 07:39:22 PDT
Created attachment 192733 [details]
Patch
Comment 4 Vsevolod Vlasov 2013-03-13 05:24:04 PDT
Comment on attachment 192733 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=192733&action=review

> Source/WebCore/inspector/front-end/CodeMirrorTextEditor.js:68
> +    this._smartBracesController = new WebInspector.CodeMirrorTextEditor.SmartBracesController(this._codeMirror);

Please move this behind a setting

> Source/WebCore/inspector/front-end/CodeMirrorTextEditor.js:515
> +            if (WebInspector.TextUtils.isWordChar(char) || (!WebInspector.TextUtils.isBraceChar(char) && WebInspector.TextUtils.isStopChar(char)))

if (!whitespace && !clsoingBrace) ?
Comment 5 Andrey Lushnikov 2013-03-18 04:48:14 PDT
Created attachment 193532 [details]
Patch
Comment 6 WebKit Review Bot 2013-03-19 01:09:29 PDT
Comment on attachment 193532 [details]
Patch

Clearing flags on attachment: 193532

Committed r146188: <http://trac.webkit.org/changeset/146188>
Comment 7 WebKit Review Bot 2013-03-19 01:09:33 PDT
All reviewed patches have been landed.  Closing bug.