integrated-application-development / integrated-application-development/pasfmt

Enforce indents/continuations must follow a line break

Open
#59 0 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
Rust
Stars
105
Forks
20
PR merge metrics
No merged PRs in 30d

Description

Currently, it's possible get `FormattingData` into a semi-invalid state pretty easily.
https://github.com/integrated-application-development/pasfmt/blob/bd8e1e874b3dbf19eeece0c8c2385776294dfd5b/core/src/lang.rs#L373-L379

You can set `indentations_before` to a non-zero value despite `newlines_before` being zero.
There's no good reason to want indentations before a token without any line breaks preceding them. It's not even useful for alignment, because you would want to use spaces for that.
The same is true of continuations.

It should be possible to leverage the type system to enforce that every indentation or continuation is preceded by a line break. In particular the `NonZero*` types in [std::num](https://doc.rust-lang.org/nightly/std/num/index.html) would be useful.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.