google / google/xls

formatting should preserve newlines introduced by the user

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

Description

**Describe the bug**
formatting should preserve newlines introduced by the user instead of trying to minimize new lines.

**To Reproduce**
Consider the following code (a):
```
assert_eq(
downcast(HF16::EXP_SIZE, HF16::FRACTION_SIZE>(
F32 { sign: u1:0, bexp: u8:0b0000_0000, fraction: u23:0b000_0000_0000_0000_0000_0000 },
u23:0), HF16 { sign: u1:0, bexp: u5:0, fraction: u10:0 });
```
And introducing new lines for readability (b):
```
assert_eq(
downcast(
F32 { sign: u1:0, bexp: u8:0b0000_0000, fraction: u23:0b000_0000_0000_0000_0000_0000 },
u23:0
),
HF16 { sign: u1:0, bexp: u5:0, fraction: u10:0 }
);
```
Will result in the code being always reformatted to (a).

**Expected behavior**

I would expect the code to stay formatted as (b).

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.