Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Fix repeated unary minus on long lines collapsing into a comment#1076

Merged
JohnnyMorganz merged 2 commits intomainfrom
feature/unary-minus
Mar 7, 2026
Merged

Fix repeated unary minus on long lines collapsing into a comment#1076
JohnnyMorganz merged 2 commits intomainfrom
feature/unary-minus

Conversation

@JohnnyMorganz
Copy link
Owner

When a chain of unary minus operators exceeded the column width, the hanging expression formatter would strip parentheses and produce output like -----5, which Lua interprets as a comment. The normal expression formatter already had protection against this, but the hanging path did not.

Extract the double-minus parenthesisation logic into a shared helper parenthesise_double_minus and call it from both code paths.

Fixes #1075

When a chain of unary minus operators exceeded the column width, the
hanging expression formatter would strip parentheses and produce output
like `-----5`, which Lua interprets as a comment. The normal expression
formatter already had protection against this, but the hanging path did
not.

Extract the double-minus parenthesisation logic into a shared helper
`parenthesise_double_minus` and call it from both code paths.

Fixes #1075
@JohnnyMorganz JohnnyMorganz enabled auto-merge (squash) March 7, 2026 11:15
@JohnnyMorganz JohnnyMorganz merged commit 13defcd into main Mar 7, 2026
21 checks passed
@JohnnyMorganz JohnnyMorganz deleted the feature/unary-minus branch March 7, 2026 11:23
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.

Unary minus can be reformatted into a comment

1 participant