Whole Tomato Software Forums
Whole Tomato Software Forums
Main Site | Profile | Register | Active Topics | Members | Search | FAQ
 All Forums
 Visual Assist
 Technical Support
 Uninvited curly brace upon auto-indent

You must be registered to post a reply.
Click here to register.

Screensize:
UserName:
Password:
Format: BoldItalicizeUnderlineStrikethrough Align leftCenterAlign right Insert horizontal ruleUpload and insert imageInsert hyperlinkInsert email addressInsert codeInsert quoted textInsert listInsert Emoji
   
Message:

Forum code is on.
Html is off.

 
Check to subscribe to this topic.
   

T O P I C    R E V I E W
jay.carlton Posted - Aug 30 2013 : 10:08:53 AM
Hi,


I have this piece of code:

    if(IsWindow(m_hWnd))
        ::GetWindowRect (m_hWnd ,&LRRectW);


And I wanted to put braces on the dependent clause, so I highlighted the call to GetWindowRect() and typed the '{' character, which put braces around it:


    if(IsWindow(m_hWnd))
        {::GetWindowRect (m_hWnd ,&LRRectW);}


So far, so good, although I'd prefer to put newlines after the first brace and before the second, but I bet I can fix that. But that's not hte hug.

If I then insert those newlines manually, I get this:


    if(IsWindow(m_hWnd))
{
    ::GetWindowRect (m_hWnd ,&LRRectW);
    }


(Note that I have the IDE's editor option to auto-indent upon tab anywhere on the line.) If I place my cursor just to the right of the open brace and hit Tab, I get this:

    if(IsWindow(m_hWnd))
    {

    } // <-- this is one more brace than I bargained for.

    ::GetWindowRect (m_hWnd ,&LRRectW);
    } 


However, if I have the cursor to the left, it auto-indents without VA X inserting a new brace. Which, as workarounds go isn't a tough one.

I can recreate this issue with a fresh snippet, so the first couple of steps can be skipped:

if (true)
{
return;
}

Is this expected, i.e. does VA X check for matching close braces before auto-adding one?

Thanks again,
Jay
2   L A T E S T    R E P L I E S    (Newest First)
jay.carlton Posted - Aug 30 2013 : 12:33:16 PM
Wow, I didn't know you could select the EOL character that way. I've always used Home and shift-end to select whole lines, but I suppose I only get visible characters that way.

That shift-down trick made my day.

-Jay
accord Posted - Aug 30 2013 : 12:17:40 PM
This also happens with Visual Assist disabled as well, so it must not be a VA feature:

VAssistX -> Enabled/Disabled Visual Assist X

However, I would suggest to select the whole line (including EOL) so you would get the desired output in one single step:

if(IsWindow(m_hWnd))
    ::GetWindowRect (m_hWnd ,&LRRectW);

Select the second line including EOL and press { to get the below:

if(IsWindow(m_hWnd))
{
    ::GetWindowRect (m_hWnd ,&LRRectW);
}


To select the whole line you can either:
- go to column 0 and press shift+down
or
- click on the margin when mouse pointer reverses its head so it points to the right
or
- triple click on the line in newer IDEs

© 2023 Whole Tomato Software, LLC Go To Top Of Page
Snitz Forums 2000