Fix Luau array access modifier formatting - #1148
Open
Companion wants to merge 1 commit into
Open
Conversation
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.
Fixes #1126
Problem
StyLua removes the separator between
readorwriteaccess modifiers and element types in Luau array shorthand:This was formatted as:
The output still parses, but refers to different types and changes the meaning of the code. Multiline forms could also misplace indentation, while a single line comment between the modifier and element could swallow the element type.
Change
Preserve the required separator after array access modifiers and route multiline indentation to the modifier when it is the first token of the element.
Trailing single line comments are terminated with a newline and the element type receives the correct indentation. Width calculations exclude trivia and count exactly one required separator, preventing types near the column limit from wrapping early.
Property and indexer access modifiers remain unchanged.
Testing
Added Luau snapshot coverage for:
readandwritearray typesThe fixed output passes
--verifyand is idempotent. Luau and all feature tests were run alongside rustfmt and clippy. The existing seven Windows specific LSP path test failures were identical on cleanmainand the changed branch.