integrated-application-development / integrated-application-development/pasfmt
Block-style formatting for integer literal arrays
- Dominant language
- Rust
- Stars
- 105
- Forks
- 20
- PR merge metrics
- No merged PRs in 30d
Description
Continuing the discussion from [#168](https://github.com/integrated-application-development/pasfmt/issues/168#issuecomment-2679759440).
Sometimes large quantities of arguments are a necessity. For example, a constant array construction:
```delphi
const
Log2DeBruijn: array[0..31] of Byte = (
00, 09, 01, 10, 13, 21, 02, 29, //
11, 14, 16, 18, 22, 25, 03, 30, //
08, 12, 20, 28, 15, 17, 24, 07, //
19, 27, 23, 06, 26, 05, 04, 31 //
);
```
With the current formatting, each element in the array would be wrapped onto its own line. With large element quantities, this can easily explode a unit's line count and degrade readability.
A proposed solution is to:
* Using some heuristics, enter a "block" mode for elements. Suggestions include:
* If all elements are integer literals
* If all elements are shorter than a configured length
* If the element count is over some threshold
* Continue placing elements inline until over the line length, then break
* Allow users to use `//` to break the line, as seen above (don't force 1-per-line like prettier though)
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.