Repository navigation
Only indent a comparison's operand by its tier when the comparison breaks - #186
Merged
Merged
Conversation
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit c24e787. Configure here.
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.

Binary operators get one indentation level per precedence tier. Comparisons are fills that stay on the line when they fit, but their tier was still counted, so the operators in their right operand ended up two levels deep with no visible reason:
Now the operators in a comparison's right operand are nested inside its fill. When the comparison stays flat they drop its tier, and when it breaks the tree-shaped layout is unchanged:
Higher precedence tiers inside the operand still nest (
+then*), and comparisons nested under a broken&&/||chain follow the same rule. The JSON example is reformatted; no other.ruefiles in the repo change.Note
Medium Risk
Changes core binary-expression emission logic in the formatter; behavior is well-covered by new tests but output diffs may affect any formatted Rue source.
Overview
Reworks binary-expression layout so comparison operators (
==,!=,<, etc.) only add an indentation tier to their right operand when the comparison actually breaks across lines.binary_spanno longer emits each operator segment inline; it buildsBinarySegmentrecords and passes them through a new recursivebinary_segmentshelper that nests the RHS insideDoc::fill_choiceflat/broken layouts. When a comparison stays on one line, nested operators in the RHS drop that comparison’s tier (fixing extra indent after==). When it breaks—or when a higher-precedence chain on the left already broke—the broken layout and tier stacking stay as before.shift_levelsadjusts indent relative to an emission reference.Doc::fillis now test-only (#[cfg(test)]); runtime formatting usesfill_choicefrom the new path. Adds formatter regression tests for flat/broken comparisons, logical chains, and nested precedence;examples/json.rueis reformatted to match.Reviewed by Cursor Bugbot for commit 1c5fedf. Bugbot is set up for automated code reviews on this repo. Configure here.