ocamlformat icon indicating copy to clipboard operation
ocamlformat copied to clipboard

Ensure that comments never move relative to tokens

Open jberdine opened this issue 7 years ago • 3 comments

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?

jberdine avatar Sep 08 '18 12:09 jberdine

I like that but aiming at never moving comments seems hard (especially with parens)

hhugo avatar Sep 08 '18 12:09 hhugo

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.

jberdine avatar Sep 08 '18 13:09 jberdine

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.

jberdine avatar May 16 '20 15:05 jberdine