llvm-project icon indicating copy to clipboard operation
llvm-project copied to clipboard

With `ColumnLimit 0`, `PackConstructorInitializers: CurrentLine` does not work as expected

Open MattijsKneppers opened this issue 2 years ago • 1 comments

Steps to reproduce In my .clang-format file, I have

ColumnLimit: 120
PackConstructorInitializers: CurrentLine

With this, the following code:

Watcher::Watcher(const fs::path& path, const WatchdogCallback& callback) : mPath(path), mCallback(callback)

stays unaltered.

However after changing ColumnLimit to 0 in .clang-format without any other changes results in:

Watcher::Watcher(const fs::path& path, const WatchdogCallback& callback) :
  mPath(path),
  mCallback(callback)

Expected behavior The documentation for ColumnLimit says:

A column limit of 0 means that there is no column limit. In this case, clang-format will respect the input’s line breaking decisions within statements unless they contradict other rules.

For PackConstructorInitializers: CurrentLine, the documentation says

Put all constructor initializers on the current line if they fit. Otherwise, put each one on its own line.

My expectation would be that this combination of ColumnLimit 0 and PackConstructorInitializers: CurrentLine means that constructor initializers will always stay in a single line.

Reproduced with Clang-Format version 16.0.6.

MattijsKneppers avatar Jun 26 '23 09:06 MattijsKneppers

@llvm/issue-subscribers-clang-format

llvmbot avatar Jun 26 '23 10:06 llvmbot

https://reviews.llvm.org/D157179

owenca avatar Aug 05 '23 07:08 owenca