Clion doesnt reformat the QT foreach construct nicely
original code:
foreach (ServerData *currentServer, servers)
{
QString sProxyString = sDefaultProxyString;
AgentProxy *pAgentProxy = new AgentProxy();
pAgentProxy->setName(currentServer->name());
m_ProxyList.append(pAgentProxy);
}
gets reformatted to:
foreach (ServerData *currentServer, servers)
{
QString sProxyString = sDefaultProxyString;
AgentProxy *pAgentProxy = new AgentProxy();
pAgentProxy->setName(currentServer->name());
m_ProxyList.append(pAgentProxy);
}
I need a workaround for this. it will also indent it to the next level
Please sign in to leave a comment.
That is know problem
CPP-2820 Qt foreach macro statement doesn't have proper code style
The problem caused by macro formatting algorithm.
There is workaround for this. It is described in article
http://stackoverflow.com/questions/14020200/how-to-config-intellij-idea-not-format-some-part-of-the-code
for your example it will:
// @formatter:off
foreach (ServerData *currentServer, servers)
{
QString sProxyString = sDefaultProxyString;
AgentProxy *pAgentProxy = new AgentProxy();
pAgentProxy->setName(currentServer->name());
m_ProxyList.append(pAgentProxy);
}
// @formatter:on
My search didnt find that. Sorry.
I voted for a fix. The workaround would have to be in too many places
thanks
Rich
The problem is still actual.
foreach(auto line, lines) {out << line << endl;
}
gets formatted to:
foreach(auto line, lines) {out << line << endl;
}