Whole Tomato Software Forums
Whole Tomato Software Forums
Main Site | Profile | Register | Active Topics | Members | Search | FAQ
User name:
Password:
Save Password
Forgot your password?

 All Forums
 Visual Assist
 Technical Support
 Uninvited curly brace upon auto-indent
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

jay.carlton
Ketchup Master

USA
65 Posts

Posted - Aug 30 2013 :  10:08:53 AM  Show Profile  Reply with Quote
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

accord
Whole Tomato Software

United Kingdom
3287 Posts

Posted - Aug 30 2013 :  12:17:40 PM  Show Profile  Reply with Quote
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

Edited by - accord on Aug 30 2013 12:18:48 PM
Go to Top of Page

jay.carlton
Ketchup Master

USA
65 Posts

Posted - Aug 30 2013 :  12:33:16 PM  Show Profile  Reply with Quote
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
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
© 2023 Whole Tomato Software, LLC Go To Top Of Page
Snitz Forums 2000