-
Notifications
You must be signed in to change notification settings - Fork 564
New line inside constructor #4138
Replies: 14 comments · 3 replies
-
I have another issue with this constructor defined in a header file: class MyClass {
public:
enum Type {
Normal,
Big,
};
explicit MyClass(const QString&name,
Type type = 0) :
_name(name),
_type(type) {
}
Type type() const {
return _type;
}
private:
QString _name;
Type _type;
}; is converted to: class MyClass {
public:
enum Type {
Normal,
Big,
};
explicit MyClass(const QString &name,
Type type = 0) :
_name(name),
_type(type) {
}
Type type() const {
return _type;
}
private:
QString _name;
Type _type;
}; |
Beta Was this translation helpful? Give feedback.
All reactions
-
Hi @guy-maurel ! I wondered if you had time to look at my issue. Thank you in advance for your help! |
Beta Was this translation helpful? Give feedback.
All reactions
-
Bonjour/bonsoir! |
Beta Was this translation helpful? Give feedback.
All reactions
-
Here it is: Details
|
Beta Was this translation helpful? Give feedback.
All reactions
-
@guy-maurel I still have the issue with 0.78.0 |
Beta Was this translation helpful? Give feedback.
All reactions
-
The problem is the function is_var_def |
Beta Was this translation helpful? Give feedback.
All reactions
-
not sure
|
Beta Was this translation helpful? Give feedback.
All reactions
-
@fwojcik : please have a look |
Beta Was this translation helpful? Give feedback.
All reactions
-
I took a look, and I think that this is a latent bug uncovered by that commit. Some variable blocks were previously ignored, and now they aren't, and the newline code is not handling class definitions correctly. The code in question ( if (pc->Is(CT_FUNC_CLASS_DEF))
{
log_rule_B("nl_var_def_blk_end");
if ( var_blk
&& options::nl_var_def_blk_end() > 0)
{
prev = pc->GetPrev();
prev = prev->GetPrev();
newline_min_after(prev, options::nl_var_def_blk_end() + 1, PCF_VAR_DEF);
pc = pc->GetNext();
first_var_blk = false;
var_blk = false;
}
} The problem is those two |
Beta Was this translation helpful? Give feedback.
All reactions
-
@MartinDelille |
Beta Was this translation helpful? Give feedback.
All reactions
-
Created a PR to fix this issue: #4161 |
Beta Was this translation helpful? Give feedback.
All reactions
-
Of course! // MyClass.h
class MyClass
{
static bool _privateVar ;
int _age;
public:
MyClass(int age);
};
// MyClass.cpp
#include "MyClass.h"
bool MyClass::_privateVar = false;
MyClass::MyClass(int age) :
_age(age) {
if (!_privateVar) {
// do something
}
} |
Beta Was this translation helpful? Give feedback.
All reactions
-
Thanks |
Beta Was this translation helpful? Give feedback.
All reactions
-
I still have the issue with uncrustify 0.78.1 |
Beta Was this translation helpful? Give feedback.
All reactions
-
Unfortunately, this fix is not in that release. It is not in any release yet, only |
Beta Was this translation helpful? Give feedback.
All reactions
-
Ok sorry I saw the release in the meantime so I thought it was part of it. I'll wait for it to be released then! |
Beta Was this translation helpful? Give feedback.
All reactions
-
I just wondered if a new release was planned including this patch ? |
Beta Was this translation helpful? Give feedback.
-
Hi,
Since uncrustify 0.77, I have the following new line with this code snippet:
is converted to:
I noticed that if I remove the static
_privateVar
initialization, the issue disappear.Beta Was this translation helpful? Give feedback.
All reactions