fix(luau): preserve space after read/write modifier in array types#1127
Open
cschanhniem wants to merge 1 commit into
Open
fix(luau): preserve space after read/write modifier in array types#1127cschanhniem wants to merge 1 commit into
cschanhniem wants to merge 1 commit into
Conversation
The TypeInfo::Array formatter merged the access modifier (read/write)
into the element type, changing code meaning. For example:
`{ read Service }` formatted to `{ readService }`
This changes the singleline path to append trailing space after the
access token (matching what format_type_field already does), and the
multiline path to place the indent trivia on the access token rather
than the element type.
Fixes JohnnyMorganz#1126
Co-authored-by: CommandCodeBot <noreply@commandcode.ai>
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.
The
TypeInfo::Arrayformatter merges the access modifier (read/write) into the element type, changing code meaning. For example:stylua --verifycorrectly detects the AST mismatch, but the formatter still produces the broken output.Root cause
In
src/formatters/luau.rs, theTypeInfo::Arrayarm formats theaccesstoken viaformat_token_referencewithout re-adding trailing trivia. The siblingformat_type_fieldfunction handles this by calling.update_trailing_trivia(FormatTriviaType::Append(...))with a space token.Fix
format_type_fieldbehavior)read\tServiceon a new line)The multiline case also now positions the access token with proper leading indent for the multiline layout.
Fixes #1126