Additional fixes on top of #2810 - #2815
Merged
Merged
Conversation
Julow
force-pushed
the
fix-2810-standalone
branch
from
July 29, 2026 15:00
d6d89f8 to
0ef5647
Compare
When a comment precedes a parenthesized match/try/function/if branch (janestreet and ahrefs profiles with parens_ite or exp_grouping=parens), glue the opening paren to the content instead of putting it alone on a line. Before: `(* cmt *)\n(\nmatch e with\n| ...)` After: `(* cmt *)\n(match e with\n | ...)` Also simplify raw_cmts_branch_pro: remove the bare_branch distinction (always emit trailing break), since paren-glue now handles the case that bare_branch was partially covering. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Tests the paren-glue behavior: with exp_grouping=parens (janestreet,
ahrefs), [begin match ... end] is parsed as a bare match needing
parenthesization; a preceding comment must not glue to the opening
paren.
Without the fix, this renders as:
(* a comment *)begin match some_long_scrutinee_expression with
| A -> a
| B -> b
end
or (with exp_grouping=parens):
(* a comment *)
(
match some_long_scrutinee_expression with
| A -> a
| B -> b)
Note: without the preceding fix, janestreet + k-r mode has a
pre-existing over-indentation issue for match-in-parens branches (match
indented +2 relative to the comment inside the parens). This caused
non-convergence with max-iters=3 in the unfixed code; the paren-glue
fix resolves the oscillation.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Julow
force-pushed
the
fix-2810-standalone
branch
from
July 29, 2026 15:07
0ef5647 to
77a3b23
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This MR fixes a few additional problems for the
if-then-else=fit-or-verticalmode. It is stacked on top of #2180.The first commit partially reverts some changes (
bare_branchlogic) in order to fix some additional less-than-ideal reformatting found on our codebase. I have added testcases, but I was not able to add the more interesting ones in a standalone commit, as ocamlformat without the fix does not stabilize in some configurations. (See the last commit.)