Author |
Topic |
|
tom_seddon
Tomato Guru
162 Posts |
Posted - Jul 30 2004 : 06:55:53 AM
|
(C++, VS.NET)
If I paste a switch/case statement, the cases are aligned incorrectly. I'm aware there is controversy surrounding the correct alignment of switch and case, but cases being one indent back from the switch is incorrect in anyone's book. (And if I have tabs at 8 and indent at 4, it is even worse.)
All is well if I turn VAX off.
|
|
feline
Whole Tomato Software
United Kingdom
19014 Posts |
Posted - Jul 30 2004 : 08:42:50 AM
|
*um* i have tried a couple of experiments, and i think i know what is going on. however, turning VAX off does not fix this for me.
running VS .NET 2003 and VAX 1246 pasting the unformatted test, from notepad:
switch(fred) {
case 1:
break;
case 2:
break;
} results in all of the case lines having zero indent, with or without VAX enabled. it looks like the formatting rule "line ending with colon means no indent" is overruling everything else.
*experiments a little more* ah, i think i have just found your case. with the C++ code:
void foo()
{
{
|
}
}
if i paste the pre-formatted text, from notepad, indents with tab:
switch(fred) {
case 1:
break;
case 2:
break;
}
with VAX enabled i am getting the same (messed up) final formatting if the caret has no indent on the blank line, or if it has the expected 2 tabs indent on the blank line.
if i turn off VAX, paste the text, then the formatting looks ok so long as the caret has no indent on the blank line.
however, if you now select the switch block and use CTRL_K + CTRL_F to format the selected lines, the IDE messes up the indent.
i believe what you are seeing, and i have reproduced is VAX pasting the text fine, and then calling the IDE's format indenting ability, which is making the mess of the switch statement.
you can turn off "format after paste" for C/C++ in the VAX options, text editor -> C/C++, which should fix the problem.
a while ago i concluded the IDE wasn't as good as indenting text as i had hoped *pines for VIM's C++ indenting abilities* |
zen is the art of being at one with the two'ness |
|
|
tom_seddon
Tomato Guru
162 Posts |
Posted - Jul 30 2004 : 11:07:18 AM
|
Yes, that sounds about right. I too have found that Ctrl-K, Ctrl-F formats it correctly (and I should have mentioned that, sorry). It doesn't look like VAX is applying a goto label rule, however, because goto labels are left-aligned, whereas the indentation for the case labels seems to be pretty random.
I guess turning VAX off fixes it for me because I have auto indent after paste switched on? |
|
|
feline
Whole Tomato Software
United Kingdom
19014 Posts |
Posted - Jul 30 2004 : 12:02:11 PM
|
do you really mean that CTRL_K + CTRL_F formats it correctly?
as for VAX format after paste, if CTRL_K + CTRL_F is making a mess then i suspect this is why disabling VAX fixes it. |
zen is the art of being at one with the two'ness |
|
|
support
Whole Tomato Software
5566 Posts |
Posted - Jul 30 2004 : 11:58:51 PM
|
feline is correct in that VA X lets the IDE format after paste, assuming you have our option enabled. |
|
|
tom_seddon
Tomato Guru
162 Posts |
Posted - Aug 02 2004 : 09:33:33 AM
|
Well, now Ctrl+K, Ctrl+F is getting it wrong. So it is the IDE's fault. Sorry, and please ignore me.
(What I was doing before was using TAB/Shift+TAB to fix up the indents, then Ctrl+K, Ctrl+F to put any #ifs back in the right place. And that seemed to work. Or at least, it used to. I blame it on this stupid "8-wide tabs with 4-space indents" that we've had to use. ) |
|
|
feline
Whole Tomato Software
United Kingdom
19014 Posts |
Posted - Aug 03 2004 : 6:35:37 PM
|
quote: Originally posted by tom_seddon
I blame it on this stupid "8-wide tabs with 4-space indents" that we've had to use.
dare i ask? this does sound most strange. |
zen is the art of being at one with the two'ness |
|
|
|
Topic |
|