Skip to content

Switch to less aggressive whitespace removal for tokens #1077

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

Closed
pokey opened this issue Oct 23, 2022 · 0 comments · Fixed by #1564
Closed

Switch to less aggressive whitespace removal for tokens #1077

pokey opened this issue Oct 23, 2022 · 0 comments · Fixed by #1564
Assignees
Labels
bug Something isn't working

Comments

@pokey
Copy link
Member

pokey commented Oct 23, 2022

Instead of removing whitespace if tokens are not merged, instead the token that is before or after the removed token can indicate whether it wants to remove whitespace.

The following tokens will remove whitespace if the token before them is deleted:

  • closing delimiters
  • comma
  • semicolon?

The following tokens will remove whitespace if the token after them is deleted:

  • closing delimiters

Note that these preferences are checked on the token that remains, not the token that was deleted. We will first check if we have trailing whitespace, then ask following token if it wants to remove whitespace. If it does not, or if there is no trailing whitespace, then try to remove leading whitespace, asking leading token if it wants that

Note that this impl requires us to factor out the code in surrounding pairs that determines whether something is an opening or closing delimiter

Examples

Input:

foo = bar.baz
"foo-bar bongo-bazman"
hello there,
"foo bar" baz-bongo
foo = bar + baz;

Desired output:

foo = baz
"foo-bar"
hello,
"foo bar" bongo
foo = bar;
@pokey pokey added the bug Something isn't working label Oct 23, 2022
@pokey pokey self-assigned this Oct 23, 2022
@AndreasArvidsson AndreasArvidsson self-assigned this Jul 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants