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

feat: format commented parenthesized expr/patterns #165

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

QuadnucYard
Copy link
Contributor

@QuadnucYard QuadnucYard commented Nov 30, 2024

This PR includes:

  • feature: parenthesized expressions can be formatted just like arrays. Nested parentheses will not be removed if there exists any comment as a direct child.
  • feature: remove unnecessary parentheses if the inner expression is literal, array, dict, destructuring, block, or pattern. For safety, parens around idents are kept.
  • change: destructuring and params with comments are no longer forced to fold into one line.

@@ -743,13 +749,19 @@ snapshot_kind: text

// Returns 'true' if the cell at (x, y)
// exists in the grid.
#let grid-has-pos(grid, x, y) = (grid-index-at(x, y, grid: grid) < grid.items.len())
#let grid-has-pos(grid, x, y) = (
grid-index-at(x, y, grid: grid) < grid.items.len()
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This respects the multiline flavor

Comment on lines +1940 to +1942
(
at_left_or_right and vline_hasnt_already_ended
)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a line break before and:

            (at_left_or_right
                and vline_hasnt_already_ended)

@QuadnucYard QuadnucYard marked this pull request as ready for review November 30, 2024 05:37
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