Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- Fixed formatting of method call chain when there is a comment between the colon token `:` and the function name ([#890](https://github.com/JohnnyMorganz/StyLua/issues/890))
- Luau: Fixed incorrect removal of semicolon before compound assignment with parentheses leading to ambiguous syntax error ([#885](https://github.com/JohnnyMorganz/StyLua/issues/885))
- Luau: Fixed incorrect collapsing of union/intersection type value with comments in a type table leading to a syntax error ([#893](https://github.com/JohnnyMorganz/StyLua/issues/893))

## [0.20.0] - 2024-01-20

Expand Down
5 changes: 4 additions & 1 deletion src/formatters/luau.rs
Original file line number Diff line number Diff line change
Expand Up @@ -861,7 +861,10 @@ pub fn format_type_field(

if let TableType::MultiLine = table_type {
// If still over budget, hang the type
if can_hang_type(type_field.value()) && shape.test_over_budget(&value) {
if can_hang_type(type_field.value())
&& (should_hang_type(type_field.value(), CommentSearch::Single)
|| shape.test_over_budget(&value))
{
value = hang_type_info(ctx, type_field.value(), TypeInfoContext::new(), shape, 1)
};

Expand Down
6 changes: 6 additions & 0 deletions tests/inputs-luau/type-tables-comments-2.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
-- https://github.com/JohnnyMorganz/StyLua/issues/893
type Foo = {
Status: "loading" -- loading
| "error" -- error
| "success" -- success
}
11 changes: 11 additions & 0 deletions tests/snapshots/tests__luau@type-tables-comments-2.lua.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
source: tests/tests.rs
expression: format(&contents)
input_file: tests/inputs-luau/type-tables-comments-2.lua
---
-- https://github.com/JohnnyMorganz/StyLua/issues/893
type Foo = {
Status: "loading" -- loading
| "error" -- error
| "success", -- success
}