Organisationsocaml-ppxocamlformatpull/2800Build History

Build History for pull/2800

Builds (9)
s/needs_raw_cmts_after_kw/is_special_or_nested_special_beginend/g
f365c5
Fix formatting oscillation in if-then-else branches When a comment sits between a keyword (then/else) and certain branch expressions (begin...end wrapping match/try/function/ifthenelse, or bare match/try/function/ifthenelse), the comment would alternate between "after keyword" and "before expression" placements across formatting iterations. This caused branch_pro to compute different indentation each time, producing "formatting did not stabilize after 10 iterations". The fix detects these oscillation-prone patterns and ensures stable formatting regardless of the initial comment placement: - In Fmt_ast, when a branch matches `needs_raw_cmts_after_kw`, extract "after keyword" comments without breaks and override branch_pro using `Params.raw_cmts_branch_pro` (which computes mode-appropriate break+indent+comment output). - In Params, `branch_pro_with_cmts` detects comments "before expression" (the alternate placement) and forces a break, producing the same layout as the "after keyword" path. - For begin...end branches, `branch_pro` checks for comments before the inner expression (not just the begin...end node) to handle the case where the comment migrates inside the begin...end scope. Affected modes: Fit_or_vertical, Compact (profile=conventional). Assisted-by: GitHub Copilot:claude-opus-4-20250514
af4faa
Fix formatting oscillation in Compact mode (profile=conventional) The same comment-oscillation bug affected the Compact if-then-else mode: a comment between a keyword (then/else) and a nested if-then-else would alternate between "after keyword" and "before expression" placements. Add branch_pro_with_cmts logic to the Compact case in Params.ml (using indent 0, since hovbox 2 provides the base indentation). Add raw_cmts_branch_pro helper to compute the correct break+indent for raw-extracted comments based on the if-then-else mode. Fixes the CI failure on js_of_ocaml/benchmarks/.../math.ml with profile=conventional.
d05ed4
Remove ~cmts_after_kw_raw parameter from get_if_then_else Move the raw comment override logic to Fmt_ast.ml instead of threading it through the Params.get_if_then_else signature. When needs_raw_cmts_after_kw detects a branch where comments would oscillate, the comments are extracted without breaks in Fmt_ast.ml and branch_pro is overridden locally before use.
1a2075
Fix formatting oscillation with comment before match in else branch Extend needs_raw_cmts_after_kw to cover bare match/try/function/ifthenelse branches (not only begin...end wrapped ones). When a long comment sits between a keyword (else/then) and such an expression, the comment would oscillate between "after keyword" and "before expression" placements across formatting iterations, causing non-stabilization. Add regression test for else-branch with long comment before match.
f29878
Lift is_special_beginend_branch to Params.Exp
5011b4
Apply review suggestions
99cd59
Apply review suggestions
b13480
Fix formatting oscillation with if-then-else=fit-or-vertical and begin...end When `if-then-else=fit-or-vertical` formats a branch containing `begin (* long comment *) if ... then ... end`, comments between the `then` keyword and `begin` would get attached to different AST locations on each formatting pass ("after" the keyword vs "before" the begin...end expression). This caused `branch_pro` to compute different indentation each time, producing an infinite oscillation that triggered "BUG: formatting did not stabilize after 10 iterations". The fix has two parts: 1. In Fmt_ast, when the if-then-else branch is a special begin...end (wrapping match/try/function/ifthenelse), relocate "after keyword" comments to "before branch" before formatting. This ensures consistent comment placement regardless of source layout. 2. In Params, when computing branch_pro for Fit_or_vertical, also check for comments before the inner expression of a special begin...end, not just before the begin...end node itself. A new helper `Cmts.relocate_after_to_before` moves comments from the "after" position of one location to the "before" position of another.
db1b40