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

Handle comments inside &&&-bulleted blocks better #82

Merged
merged 3 commits into from
Jul 19, 2024

Conversation

jaybosamiya-ms
Copy link
Collaborator

@jaybosamiya-ms jaybosamiya-ms commented Jul 16, 2024

The interaction of comments and bulleted blocks previously caused surprising number of newlines to show up. This PR fixes this.

In particular, the following code is now considered correctly-formatted

fn foo() {
    // these should stay together
    &&& x
    &&& y
    // xy
    &&& xy
    // zzz
    &&& z
}

Previously, there would be unnecessary newlines added after every comment. This would happen because comments have a forced-hardline after them, while &&& (and |||) bullets have a forced hardline before them, causing the number of hardlines to double-up, leading to surprising looking code.

Example sub-optimal code with the old surprising behavior (issue reported by Johanna (@JoPolzin)):
image


Note: this particular change causes a single-line change to the Verus vstd snapshot, but still requires a tiny amount of coordination to prevent spurious CI failures there before releasing (should not block merging, just blocks release, and should likely bump the minor version, rather than just patch version).

Copy link
Contributor

@parno parno left a comment

Choose a reason for hiding this comment

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

I'm impressed you could make this work with such a minor diff to lib.rs!

@jaybosamiya-ms jaybosamiya-ms merged commit a730d04 into main Jul 19, 2024
8 checks passed
@jaybosamiya-ms jaybosamiya-ms deleted the jb-comments-in-bulleted-and branch July 19, 2024 00:36
@jaybosamiya-ms
Copy link
Collaborator Author

Yeah given that the comment is at a non-local nesting, I was worried it'd be a fairly complex fix, but once I realized I could flatten things, the diff became a lot smaller than the previous prototype of this that I was working with :)

@JoPolzin
Copy link

This is actually beautifull. I love it. Thanks :)

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.

3 participants