Hey Guys,
does the Autocomplete-Plugin already support C++0x? On my machine it for example doesn't indent blocks like "for(auto x : list)" properly.
greetings,
Halan
This indents as expected on my computer.
Are you using a nightly? How does what actually happens differ from what you expected to happen?
Are you sure it's working properly on your machine?
With the latest stable it doesn't get indented at all, with the latest nightly it gets one tab less indented as expected...
I am not sure if I completely understand what (or even if) the problem is; could you please:
a. Post a snippet of code that you enter. (Using code tags.)
b. Post a snippet of code showing what (if anything) Code::Blocks does to change/auto-format it. (Using code tags.)
and
c. Post a snippet of code showing what it is you would have liked Code::Blocks to have changed/auto-formatted it to. (And again, using code tags.)
I am willing to look into this when I have time (I have messed around with that part of the code recently :), so I think I know my way around it), but simply do not know what I am supposed to be trying to fix it to do.
Looks at this source code for example
{
bool ok = true;
for(auto it: events)
ok = ok && this->subscribeEvent(elem, it);
return ok;
}
The for-loop isn't indented correctly..
Now I understand. Try the following patch.
Index: src/plugins/astyle/astyle/ASBeautifier.cpp
===================================================================
--- src/plugins/astyle/astyle/ASBeautifier.cpp (revision 7900)
+++ src/plugins/astyle/astyle/ASBeautifier.cpp (working copy)
@@ -2373,9 +2373,9 @@
tabCount += classInitializerTabs;
}
- else if (isJavaStyle() && lastLineHeader == &AS_FOR)
+ else if ((isJavaStyle() || isCStyle()) && lastLineHeader == &AS_FOR)
{
- // found a java for-each statement
+ // found a java/C++0x for-each statement
// so do nothing special
}
I suggest OP give us a step by step instructions, so we won't guess.
It should related to CodeCompletion OR cbEditor, not astyle, right?
The AStyle plugin was the only thing I could get to reproduce this behavior. (Although the lack of steps is why it took me some time to track it down.)
Yeah I am using the AStyle formatter. Didn't even know there were other sourcecode-formatters in Code::Blocks.
And sorry, I thought my last post made the behaviour clear..
@Developers: The patch in my previous post appears to solve the problem (although it would probably be best if the OP could confirm this as well). Is this something that should be submitted to Code::Block's patch tracker, or to the actual AStyle project? (If it is the AStyle project, could someone who already has a SourceForge account submit it there - I do not really want to create an account just for a single action.)
Quote from: Alpha on March 25, 2012, 08:57:28 PM
Is this something that should be submitted to Code::Block's patch tracker, or to the actual AStyle project?
This is astyle, not Code::Blocks. However, you should first look at the astyle code whether this has probably been fixed already. You can integrate later versions of astyle easily into Code::Blocks, just make sure you keep these two methods in the public section:
void setBlockIndent(bool state);
void setBracketIndent(bool state);
Quote from: MortenMacFly on March 26, 2012, 07:07:33 AM
However, you should first look at the astyle code whether this has probably been fixed already.
You were right; I checked the AStyle project, and it appears this problem has already been fixed. Patch #3268 (https://developer.berlios.de/patch/index.php?func=detailpatch&patch_id=3268&group_id=5358) updates Code::Blocks to this.
Quote from: Alpha on March 28, 2012, 12:34:08 AM
Patch #3268 (https://developer.berlios.de/patch/index.php?func=detailpatch&patch_id=3268&group_id=5358) updates Code::Blocks to this.
You don't need to provide patches - I am maintaining this already, but thanks anyways.
OK.
Just wondering, is this commited upstream now?
I am using the packages from Jens' repository and I still have this formatting issue :/
Quote from: Halan on May 12, 2012, 11:18:57 AM
Just wondering, is this commited upstream now?
No, whats missing is the integration of the new features to the UI.
I may do an interim-commit, but this would mean that you cannot setup all features.
Quote from: MortenMacFly on May 12, 2012, 03:17:09 PM
Quote from: Halan on May 12, 2012, 11:18:57 AM
Just wondering, is this commited upstream now?
No, whats missing is the integration of the new features to the UI.
I may do an interim-commit, but this would mean that you cannot setup all features.
Isn't this just a small patch for supporting these new-style lopps?
Quote from: Halan on May 22, 2012, 01:30:58 PM
Isn't this just a small patch for supporting these new-style lopps?
Yes.