Skip to content

Various trivia-related fixes. #648

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

Merged
merged 3 commits into from
Oct 12, 2023
Merged

Conversation

allevato
Copy link
Member

These are fixes that got missed during the removal of the legacy trivia workaround (and one issue that's been around before that):

  • // swift-format-ignore-file shouldn't modify anything, even whitespace.
  • NoParensAroundConditions: Preserve trailing trivia on the statement keyword.
  • OrderedImports: Fix trivia placement for trailing comments.

…eyword.

After removing the legacy trivia workaround, we were dropping trailing
trivia on a conditional statement keyword; for example, the comment would
be lost here:

```swift
guard  // here's a comment
  let x = x
else {}
```
Trailing comments were being appended to the next token's leading
trivia instead of staying as trailing trivia; I forgot to make this
adjustment when removing the legacy trivia workaround. Interestingly,
this didn't surface as a problem in either the `OrderedImports`
rule's unit tests or the pretty printer unit tests. Only the
interaction between the two would surface the error.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant