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

Grainfmt: Support formatter-ignore in more places #2040

Open
phated opened this issue Feb 19, 2024 · 0 comments
Open

Grainfmt: Support formatter-ignore in more places #2040

phated opened this issue Feb 19, 2024 · 0 comments
Labels
grainfmt Issues related to the Grain formatter

Comments

@phated
Copy link
Member

phated commented Feb 19, 2024

As per @ospencer at #1976 (comment)

We currently only support it on statements, so that's either top-level statements or statements within a block. We could open an issue to support it in more places, though it's a little tricky/could give unexpected results in some cases:

func(
  // formatter-ignore
  1+2, 2+3, 3+4
)

formatter-ignore is supposed to apply to the next node rather than the next line, so it could be expensive to check for that. We can't make it apply to all 3 arguments because they're treated as three separate nodes. Formatting once would place them on separate lines, making the formatter-ignore comment no longer apply to the second two nodes, so formatting again would actually format them (which is very bad behavior).

Trying to just cut out that one line is even trickier business since you could easily split across AST nodes. So we'd probably need to do that expensive check instead, but now we've got a super expensive check for every AST node.

It might be possible to not make it horribly expensive, but I'd have to think about it.

@spotandjake spotandjake added the grainfmt Issues related to the Grain formatter label Jun 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
grainfmt Issues related to the Grain formatter
Projects
None yet
Development

No branches or pull requests

2 participants