Skip to content

A newline is added after a string token if the next 2 tokens are lessless and string #44363

@JvdGlind

Description

@JvdGlind
Bugzilla Link 45018
Version trunk
OS Windows NT
Attachments File to verify two streamed strings aren't split

Extended Description

Given the code:

QStringList() << "something" << "something" << variable;

If I then run clang-format with the default config file, the output is the following code:

QStringList() << "something"
<< "something" << variable

What I expected, was that it stays on a single line, unless it exceeds the column limit and possible penalties. In this case, untouched.

It stays untouched when I add a variable in between:

QStringList() << "something" << a << "something" << variable;

Looking at the code, I noticed that somebody intentionally introduced this to split endline characters in commit df28f7b8dd6a032515109de4ff5b4067be95da8e (currently at lib/Format/TokenAnnotator.cpp, line 3073).

In the attachment I added a file with a slightly different example that I used when debugging clang-format.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions