Whole Tomato Software Forums
Whole Tomato Software Forums
Main Site | Profile | Register | Active Topics | Members | Search | FAQ
 All Forums
 Visual Assist
 Technical Support
 #if / #endif indentation problem

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
Adequat Posted - Jul 26 2013 : 06:00:52 AM
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
8   L A T E S T    R E P L I E S    (Newest First)
accord Posted - Aug 01 2013 : 1:58:26 PM
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.
sean Posted - Aug 01 2013 : 09:50:08 AM
[previous comment removed since I was on a completely different planet]

Makes sense.

case=75861
Adequat Posted - Aug 01 2013 : 05:55:38 AM
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...
accord Posted - Jul 31 2013 : 11:23:39 AM
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.
Adequat Posted - Jul 30 2013 : 08:18:07 AM
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?
feline Posted - Jul 29 2013 : 12:06:40 PM
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
Adequat Posted - Jul 26 2013 : 11:46:20 PM
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...
accord Posted - Jul 26 2013 : 7:34:52 PM
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.

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