Skip to content

Target first attribute at_sign in stmt_remove_leading_newlines for LocalFunction/ConstFunction#1115

Merged
JohnnyMorganz merged 6 commits into
mainfrom
claude/fix-stylua-1109-UiHRw
May 16, 2026
Merged

Target first attribute at_sign in stmt_remove_leading_newlines for LocalFunction/ConstFunction#1115
JohnnyMorganz merged 6 commits into
mainfrom
claude/fix-stylua-1109-UiHRw

Conversation

@JohnnyMorganz
Copy link
Copy Markdown
Owner

When a LocalFunction or ConstFunction has a leading Luau attribute (e.g. @Native),
the actual first token of the statement is the attribute's at_sign, not the local/const
keyword. stmt_remove_leading_newlines was targeting the wrong token, leaving stray
newlines before the attribute at the start of a block.

Fixes #1109

claude added 6 commits May 16, 2026 08:16
…or LocalFunction/ConstFunction

When a LocalFunction or ConstFunction has a leading Luau attribute (e.g. @Native),
the actual first token of the statement is the attribute's at_sign, not the local/const
keyword. stmt_remove_leading_newlines was targeting the wrong token, leaving stray
newlines before the attribute at the start of a block.

Fixes #1109
…cation on no-attribute path

- Deduplicate the identical 6-line attribute-stripping logic from LocalFunction
  and ConstFunction arms into a single helper function
- Use peekable iterator so no Vec is allocated when the function has no attributes
  (the common case)
- Make both arms use a consistent if-let pattern instead of early-return vs if/else
- Remove redundant comment from test input file
Replace peek()+collect()+[0]+clone() with cloned().next()? which takes the
first element as an owned value so with_at_sign can consume it directly.
@codecov
Copy link
Copy Markdown

codecov Bot commented May 16, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.66%. Comparing base (4df5c84) to head (1b8676b).
⚠️ Report is 3 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1115   +/-   ##
=======================================
  Coverage   96.66%   96.66%           
=======================================
  Files          16       16           
  Lines        5307     5308    +1     
=======================================
+ Hits         5130     5131    +1     
  Misses        177      177           

☔ 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.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@JohnnyMorganz JohnnyMorganz changed the title fix: target first attribute at_sign in stmt_remove_leading_newlines for LocalFunction/ConstFunction Target first attribute at_sign in stmt_remove_leading_newlines for LocalFunction/ConstFunction May 16, 2026
@JohnnyMorganz JohnnyMorganz merged commit 8b22575 into main May 16, 2026
23 checks passed
@JohnnyMorganz JohnnyMorganz deleted the claude/fix-stylua-1109-UiHRw branch May 16, 2026 11:14
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.

stmt_remove_leading_newlines ignores attributes on LocalFunction/ConstFunction

2 participants