Skip to content

Commit 145a7c3

Browse files
authored
Fix formatting of index containing brackets string in parentheses (#992)
1 parent 992568d commit 145a7c3

File tree

6 files changed

+24
-0
lines changed

6 files changed

+24
-0
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
### Fixed
11+
- Fix formatting of index containing brackets string in parentheses ([#992](https://github.com/JohnnyMorganz/StyLua/pull/992))
12+
1013
## [2.1.0] - 2025-04-21
1114

1215
### Added

src/formatters/expression.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -369,6 +369,7 @@ pub fn is_brackets_string(expression: &Expression) -> bool {
369369
..
370370
}
371371
),
372+
Expression::Parentheses { expression, .. } => is_brackets_string(expression),
372373
#[cfg(feature = "luau")]
373374
Expression::TypeAssertion { expression, .. } => is_brackets_string(expression),
374375
_ => false,
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
local foo = {
22
[ [[test]] :: test ] = true,
3+
[ ([[foo]]) :: test ] = true,
4+
[ ( [[bar]] ) :: test ] = true,
35
}
46

57
foo[ [[test]] :: test ] = false
8+
foo[ ([[foo]]) :: test ] = false
9+
foo[ ( [[bar]] ) :: test ] = false
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
local foo = {
22
[ [[test]] ] = true,
3+
[([[foo]])] = true,
4+
[( [[bar]] )] = true,
5+
[ ([[baz]]) ] = true,
36
}
47

58
foo[ [[test]] ] = false
9+
foo[([[foo]])] = true
10+
foo[( [[bar]] )] = true
11+
foo[ ([[baz]]) ] = true

tests/snapshots/[email protected]

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,11 @@ input_file: tests/inputs-luau/string-brackets-index.lua
55
---
66
local foo = {
77
[ [[test]] :: test ] = true,
8+
[ ([[foo]]) :: test ] = true,
9+
[ ([[bar]]) :: test ] = true,
810
}
911

1012
foo[ [[test]] :: test ] = false
13+
foo[ ([[foo]]) :: test ] = false
14+
foo[ ([[bar]]) :: test ] = false
1115

tests/snapshots/[email protected]

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,13 @@ expression: format(&contents)
44
---
55
local foo = {
66
[ [[test]] ] = true,
7+
[ [[foo]] ] = true,
8+
[ [[bar]] ] = true,
9+
[ [[baz]] ] = true,
710
}
811

912
foo[ [[test]] ] = false
13+
foo[ [[foo]] ] = true
14+
foo[ [[bar]] ] = true
15+
foo[ [[baz]] ] = true
1016

0 commit comments

Comments
 (0)