ocamlformat
ocamlformat copied to clipboard
Ensure that comments never move relative to tokens
To summarize the variety of potential issues with comment placement, I wonder if it is feasible to aim to ensure that comments never move relative to tokens. If we could ensure that, it would be a very clear description of the expected behavior. (How the comments in each position should affect formatting would be another problem.) @hhugo, would you be optimistic about using Source.tokens_at or similar to influence the comment placement decisions?
I like that but aiming at never moving comments seems hard (especially with parens)
Yes, parens might be hard. An intermediate point could be to have a small set of tokens that are allowed to move, like parens, and still leave us in a more robust situation.
Is this, or a slightly weaker version that allows motion relative to parens, be something that ought to be added to the 1.0 wishlist? So far, this is the only candidate I know for a simple specification of what the placement of comments should do.