Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enforce indents/continuations must follow a line break #59

Open
zaneduffield opened this issue Apr 11, 2024 · 0 comments
Open

Enforce indents/continuations must follow a line break #59

zaneduffield opened this issue Apr 11, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@zaneduffield
Copy link
Collaborator

Currently, it's possible get FormattingData into a semi-invalid state pretty easily.

pasfmt/core/src/lang.rs

Lines 373 to 379 in bd8e1e8

pub struct FormattingData {
ignored: bool,
pub newlines_before: usize,
pub indentations_before: usize,
pub continuations_before: usize,
pub spaces_before: usize,
}

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 would be useful.

@zaneduffield zaneduffield changed the title Enforce idents/continuations must follow a line break Enforce indents/continuations must follow a line break Apr 11, 2024
@zaneduffield zaneduffield added the enhancement New feature or request label Jan 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant