google / google/xls

dslx_fmt should not insert blank line before comments between functions

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

Description

**Describe the bug**
Not sure if that's intentional, but it seems that dslx_fmt systematically insert a blank line on a comment that appear between two functions.

**To Reproduce**
```
fn foo() -> u32 {
let a = 0;
a
}
// foo

#[test]
fn foo_test() {
let x = foo();
assert_eq(x, u32:0);
}
```
gets reformatted as:
```
fn foo() -> u32 {
let a = 0;
a
}

// foo

#[test]
fn foo_test() {
let x = foo();
assert_eq(x, u32:0);
}
```

**Expected behavior**

dslx_fmt doesn't insert a blank line before the comment.

**Additional context**

Note that this doesn't happen if the function is last in the file:
```
fn foo() -> u32 {
let a = 0;
a
}
// foo
```

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.