Skip to content

[Bug]: Bad trailing whitespace trimming #424

@QuadnucYard

Description

@QuadnucYard

What happened?

This is a problem that has always existed, but has not affected its use.
We always trim trailing whitespaces to avoid non-empty blank lines and unexpected spaces after separators. However, this is a bad idea for multiline strings and raws.

For example:

#"1 
 
2"

There are invisible trailing spaces in L1 and L2. The string changes if we trim these spaces.
That is the same for raws.

To fix this, we need to revamp the pretty engine.
As a reference, the biome formatter uses a weak space/line model to avoid producing unnecessary whitespaces.

Playground link

https://typstyle-rs.github.io/typstyle/playground/?code=MQIgjABAsAUNMCYRA

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions