-
Notifications
You must be signed in to change notification settings - Fork 226
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Formatter: Align multiline string initializer #834
Formatter: Align multiline string initializer #834
Conversation
3138505
to
dab41ee
Compare
dab41ee
to
f69ae47
Compare
2ba989a
to
60dc7a8
Compare
The partitions in "wrapped first subpartition" mode use their existing indentation now. This has been done to support different use cases, e.g. wrapped function arguments (8 spaces), or strings inside concatenation expressions (4 spaces).
60dc7a8
to
8c2f1db
Compare
@hzeller could you please take a look at this too? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice!
// Wrapped first argument | ||
wrapped_first_subpartition = true; | ||
} else { | ||
bool wrapped_first_subpartition; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Below, this value is essentially depending on the result of the !wrap_first_subpartition && (fit_result = FitsOnLine(first_line, style)).fits == true)
if condition (if I see it correctly).
So maybe we can assign the value direclty and make it const.
const bool wrapped_first_subparition = ....
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
{"string abc[] = {//\n" | ||
"\"a\", \"b\", \"c\"" | ||
"};\n", | ||
"string abc[] = { //\n" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if some of these strings would be a bit more readable using c++11 raw string literals to have the expected string shine through more with less escape-backslashes needed.
In general, the strings are fine, leaving it up to you to experiment with that option.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Raw literals could be used only for strings that don't have \n
- otherwise we'll need an extra "\n"
which are put in separate lines by autoformatter. I think it's better to avoid those few "different" lines and keep everything uniform.
Or did you mean multiline raw strings? Like:
{R"(string abc[]= {//
"a", "b", "c"
};
)",
R"(string abc[] = { //
"a",
"b",
"c"
};
)"}
I think we can merge this |
This crashes when run over all ibex files; in the following example https://github.com/lowrisc/ibex was checked out to
Bisecting shows that this is the commit where that happens. Can you roll back @tgorochowik @mglb ? (since there were other commits afterwards, it is not a simple reverse patch unfortunately). |
(or fixing and roll-forward is also an option of course) |
Sure, we'll take a look at this |
Demo:
Closes #41