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
 #if / #endif indentation problem
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Adequat
Tomato Guru

182 Posts

Posted - Jul 26 2013 :  06:00:52 AM  Show Profile  Reply with Quote
Let's say I have this code:





I want to add {...} around it, using VA "surround selection...". Here's what I get:





But here's what I expected:




In other words, VA changes the #if / #endif indentation without my will. How can I avoid this?
VA assumes the #if / #endif always start at column 0, but this not my choice.
This is not new, but this gets on my nerves for years

accord
Whole Tomato Software

United Kingdom
3287 Posts

Posted - Jul 26 2013 :  7:34:52 PM  Show Profile  Reply with Quote
Visual Assist applies an auto formatting after the surround snippet, because it is usually helpful. However, 2 undo buffer is saved while the operation, so if you don't want formatting just press undo (e.g. alt+z) once. A second undo would be needed to remove the surrounding brackets as well.
Go to Top of Page

Adequat
Tomato Guru

182 Posts

Posted - Jul 26 2013 :  11:46:20 PM  Show Profile  Reply with Quote
Thanks for the trick, though this is not perfect, as the 1st undo operation moves the { } to column 0.
Code formatting is such a personal thing that it should either be optional or customizable...
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
18755 Posts

Posted - Jul 29 2013 :  12:06:40 PM  Show Profile  Reply with Quote
Since there are so many different styles and opinions on code formatting, allowing this to be properly customizable is quite a big job. Depending on your IDE you might want to look into this extension, which is designed to help give you the code formatting you want:

http://www.profactor.co.uk/stylemanager.php

zen is the art of being at one with the two'ness
Go to Top of Page

Adequat
Tomato Guru

182 Posts

Posted - Jul 30 2013 :  08:18:07 AM  Show Profile  Reply with Quote
Note that what I request is simply "don't change my code formatting", that shouldn't be too difficult to achieve ;-)
After all, the other VA function to surround a block with /* */ is preserving the code layout...
And finally, this is not the *purpose* of the { } surrounding function to change the inner code layout, no?
Go to Top of Page

accord
Whole Tomato Software

United Kingdom
3287 Posts

Posted - Jul 31 2013 :  11:23:39 AM  Show Profile  Reply with Quote
This snippet works the following way:

1. It inserts { in the first line at column 0
2. It runs the IDE's code formatting feature for the selection which now includes the { and }.



This "format selection" works pretty well for most cases but not always. But if we tuned it off, you would get the result which can be seen on the second screenshot.

Edited by - accord on Jul 31 2013 11:28:01 AM
Go to Top of Page

Adequat
Tomato Guru

182 Posts

Posted - Aug 01 2013 :  05:55:38 AM  Show Profile  Reply with Quote
Thanks for your presentation, but your example does not show the case where #if / #endif statements are part of the selection to surround with { }, and the problem I describe only happens in this scenario...
Go to Top of Page

sean
Whole Tomato Software

USA
2817 Posts

Posted - Aug 01 2013 :  09:50:08 AM  Show Profile  Reply with Quote
[previous comment removed since I was on a completely different planet]

Makes sense.

case=75861

Edited by - sean on Aug 01 2013 09:51:45 AM
Go to Top of Page

accord
Whole Tomato Software

United Kingdom
3287 Posts

Posted - Aug 01 2013 :  1:58:26 PM  Show Profile  Reply with Quote
My point was that turning off the indentation wouldn't have the desired effect in itself, so we need a different solution.

Sean's bug report addresses the indentation problem via handling lines with #directives in a different way, thus getting the desired outcome.

Edited by - sean on Aug 01 2013 2:00:39 PM
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