google / google/xls

autofmt removes blank lines between proc/struct/enum members

Open
#1,551 0 comments 0 reactions 0 assignees View on GitHub
bug dslx dslx:fmt fmt:whitespace
Dominant language
C++
Stars
1.9k
Forks
283
Avg merge
2d 10h
Merged PRs (30d)
135

Description

**Describe the bug**
Maybe more but I noticed that these aggregates aggressively strip blank lines, whereas functions preserve a single blank line which may be intentional for readability to denote logical separation of code.

**To Reproduce**
Run the following code through the autoformatter:

```
proc my_proc {
// foo section
// x data
foo_x: chan out;
// y data
foo_y: chan out;

// bar section
// x data
bar_x: chan out;
// y data
bar_y: chan out;

// baz section
// x data
baz_x: chan out;
// y data
baz_y: chan out;
...
}
```

See the code reformatted to:

```
proc my_proc {
// foo section
// x data
foo_x: chan out;
// y data
foo_y: chan out;
// bar section
// x data
bar_x: chan out;
// y data
bar_y: chan out;
// baz section
// x data
baz_x: chan out;
// y data
baz_y: chan out;
...
}
```

Same behavior can be seen in enum and struct definitions.

**Expected behavior**
The autoformatter should preserve the notion of subsections within these composites. It already does for code within functions, e.g.

```
fn my_function() {
// some code block
let foo = u32:1;
let bar = u32:0;

// return the sum
foo + bar
}
```

does not get reformatted to:

```
fn my_function() {
// some code block
let foo = u32:1;
let bar = u32:0;
// return the sum
foo + bar
}
```

though it would remove extra blank lines beyond 1.

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.