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 @@ -7,6 +7,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]
### Fixed
- Fixed indentation of type callback specifier parameters when parameters have leading comment trivia. ([#278](https://github.com/JohnnyMorganz/StyLua/issues/278))
- Fixed trailing comma not being taken into account when determining the width of a field in a multiline table. ([#282](https://github.com/JohnnyMorganz/StyLua/issues/282))

## [0.11.0] - 2021-09-16
### Changed
Expand Down
2 changes: 1 addition & 1 deletion src/formatters/table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ where
let (field, punctuation) = (pair.value(), pair.punctuation());

// Reset the shape onto a new line, as we are a new field
shape = shape.reset();
shape = shape.reset().add_width(1); // Add 1 to include the trailing comma at the end

// Format the field
let (formatted_field, mut trailing_trivia) = formatter(ctx, field, table_type, shape);
Expand Down
4 changes: 4 additions & 0 deletions tests/inputs/table-5.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
a = {
key1 = string.format("test", "test", "test", "test", "test", "test", "test", "test", "test", "test", variable_names),
key2 = string.format("test", "test", "test", "test", "test", "test", "test", "test", "test", "test", variable_names),
}
34 changes: 34 additions & 0 deletions tests/snapshots/tests__standard@table-5.lua.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
---
source: tests/tests.rs
expression: format(&contents)

---
a = {
key1 = string.format(
"test",
"test",
"test",
"test",
"test",
"test",
"test",
"test",
"test",
"test",
variable_names
),
key2 = string.format(
"test",
"test",
"test",
"test",
"test",
"test",
"test",
"test",
"test",
"test",
variable_names
),
}