feat: Correctly inline opening parentheses#100
feat: Correctly inline opening parentheses#100shssoichiro merged 2 commits intoshssoichiro:masterfrom
Conversation
11c7a97 to
dfa1454
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #100 +/- ##
==========================================
- Coverage 99.24% 99.23% -0.01%
==========================================
Files 6 6
Lines 3558 3646 +88
Branches 3558 3646 +88
==========================================
+ Hits 3531 3618 +87
- Misses 19 20 +1
Partials 8 8 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull Request Overview
This PR implements functionality to correctly inline opening parentheses in SQL formatting. The changes enable specific formatting behavior where opening parentheses can be placed on the same line as the preceding keyword when certain conditions are met, rather than always starting a new line.
- Enhances the
SpanInfostruct to track additional metadata for formatting decisions - Implements logic to detect when opening parentheses should be inlined with preceding keywords
- Updates indentation handling to support "folded blocks" that don't contribute to indentation depth
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/lib.rs | Adds new fields to SpanInfo struct and includes test case for inline parentheses behavior |
| src/inline_block.rs | Modifies begin_if_possible method to return boolean indicating if inlining occurred |
| src/indentation.rs | Adds support for folded block indentation type and updates indentation calculation |
| src/formatter.rs | Implements core logic for detecting and formatting inline opening parentheses |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| if arguments == 0 { | ||
| arguments += 1 |
There was a problem hiding this comment.
The logic for counting arguments is incorrect. This code increments arguments for every non-comma token when arguments is 0, which means arguments will always be at least 1 even for empty parameter lists. This should only increment when encountering the first actual argument token, not for every token.
| if arguments == 0 { | |
| arguments += 1 | |
| // Only increment arguments for the first actual argument token, | |
| // and only if it's not whitespace, parentheses, or reserved keywords. | |
| // Only increment arguments for the first actual argument token, | |
| // and only if it's not whitespace, parentheses, or reserved keywords. | |
| if arguments == 0 { | |
| arguments += 1; | |
| TokenKind::Whitespace | |
| | TokenKind::OpenParen | |
| | TokenKind::CloseParen | |
| | TokenKind::ReservedTopLevel | |
| | TokenKind::ReservedTopLevelNoIndent | |
| | TokenKind::ReservedNewlineAfter | |
| | TokenKind::Operator if token.value == "," => {} | |
| _ => arguments += 1, | |
| } |
There was a problem hiding this comment.
I'm not sure if the comment is valid or not, but I know for sure the code suggestion is broken.
No description provided.