Skip to content
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

Make Definition Block Spacing Configurable #57180

Open
codeinred opened this issue Aug 16, 2022 · 3 comments
Open

Make Definition Block Spacing Configurable #57180

codeinred opened this issue Aug 16, 2022 · 3 comments
Assignees
Labels
awaiting-review Has pending Phabricator review clang-format

Comments

@codeinred
Copy link

codeinred commented Aug 16, 2022

As it currently exists, the SeparateDefinitionBlocks option only allows for no spacing (SDS_Never), or exactly one space (SDS_Always). The amount of space should be configurable, especially as some organizations require two spaces between blocks as part of their formatting style.

In the ideal case, an option such as DefinitionBlockSpacing would be added to allow users to set a custom amount of space between definition blocks. For example,

SeparateDefinitionBlocks: Always
DefinitionBlockSpacing: 2

Would result in two lines being used to separate definition blocks.

@llvmbot
Copy link
Collaborator

llvmbot commented Aug 16, 2022

@llvm/issue-subscribers-clang-format

codeinred added a commit to codeinred/llvm-project that referenced this issue Aug 17, 2022
Fixes llvm#57180

Given configuration:

```
SeparateDefinitionBlocks: Always
DefinitionBlockSpacing: 2
```

Two spaces will be inserted between definition blocks. Code before
formatting:

```
/// f is a function
void f() {
    // Some code
    // More code
    return;
}
/// g is another function
void g() {
    // Some other code
}
```

Versus code after formatting:

```
/// f is a function
void f() {
    // Some code
    // More code
    return;
}
​
​
/// g is another function
void g() {
    // Some other code
}
```

Note: two zero width spaces were inserted into the commit message in
order to prevent git from removing the additional lines inside the
commit. These will not appear in formatted code.
@codeinred
Copy link
Author

Update: I've implemented this feature here. I'll be submitting this patch for review.

@codeinred
Copy link
Author

Update: Patch submitted for review: https://reviews.llvm.org/D132256

@HazardyKnusperkeks HazardyKnusperkeks added the awaiting-review Has pending Phabricator review label Aug 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting-review Has pending Phabricator review clang-format
Projects
None yet
Development

No branches or pull requests

4 participants