Skip to content

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

@carljohnsonnewhampshire-hue

Description

I have the following .clang-format config:

SeparateDefinitionBlocks: Always
MaxEmptyLinesToKeep: 2

The following C++ code:

struct A {};


struct B {};

Is formatted as:

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions