Skip to content

feat: Correctly inline opening parentheses#100

Merged
shssoichiro merged 2 commits intoshssoichiro:masterfrom
lu-zero:inline-opening-parentheses
Sep 16, 2025
Merged

feat: Correctly inline opening parentheses#100
shssoichiro merged 2 commits intoshssoichiro:masterfrom
lu-zero:inline-opening-parentheses

Conversation

@lu-zero
Copy link
Copy Markdown
Contributor

@lu-zero lu-zero commented Sep 15, 2025

No description provided.

@lu-zero lu-zero force-pushed the inline-opening-parentheses branch from 11c7a97 to dfa1454 Compare September 15, 2025 14:18
@codecov
Copy link
Copy Markdown

codecov bot commented Sep 15, 2025

Codecov Report

❌ Patch coverage is 98.64865% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 99.23%. Comparing base (d20763c) to head (64c48ec).
⚠️ Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
src/formatter.rs 98.94% 1 Missing ⚠️
src/indentation.rs 95.23% 1 Missing ⚠️
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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@shssoichiro shssoichiro requested a review from Copilot September 16, 2025 03:09
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 SpanInfo struct 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.

Comment on lines +627 to +628
if arguments == 0 {
arguments += 1
Copy link

Copilot AI Sep 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
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,
}

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if the comment is valid or not, but I know for sure the code suggestion is broken.

@shssoichiro shssoichiro merged commit 1ce0359 into shssoichiro:master Sep 16, 2025
6 of 8 checks passed
@lu-zero lu-zero deleted the inline-opening-parentheses branch October 1, 2025 05:15
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.

3 participants