llvm / llvm/llvm-project

[clang-format]: `SeparateDefinitionBlocks` doesn't respect `MaxEmptyLinesToKeep`

Open
#168,702 4 comments 0 reactions 0 assignees View on GitHub
clang-format confirmed
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

I have the following .clang-format config:
```
SeparateDefinitionBlocks: Always
MaxEmptyLinesToKeep: 2
```
The following C++ code:
```C++
struct A {};

struct B {};
```
Is formatted as:
```C++
struct A {};

struct B {};
```
Which is not what I intended or expected it to be formatted like with this config. I expected this code to be left as is, and obviously if there was no empty lines between A and B struct definitions, I would expect one empty line to be added between them, but not two empty lines to be collapsed into one empty line, given that I have `MaxEmptyLinesToKeep` set to `2`.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.