File tree Expand file tree Collapse file tree 2 files changed +17
-5
lines changed Expand file tree Collapse file tree 2 files changed +17
-5
lines changed Original file line number Diff line number Diff line change @@ -11,6 +11,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) a
11
11
- The ability to "check" formatting by formatting the output of the first format.
12
12
- Comments can now be attached to the ` case ` keyword.
13
13
- Remove escaped forward slashes from regular expression literals when converting to ` %r ` .
14
+ - Allow arrays of ` CHAR ` nodes to be converted to ` QWords ` under certain conditions.
14
15
15
16
### Changed
16
17
Original file line number Diff line number Diff line change @@ -1355,7 +1355,11 @@ def format(q)
1355
1355
q . indent do
1356
1356
q . breakable ( "" )
1357
1357
q . seplist ( contents . parts , -> { q . breakable } ) do |part |
1358
- q . format ( part . parts . first )
1358
+ if part . is_a? ( StringLiteral )
1359
+ q . format ( part . parts . first )
1360
+ else
1361
+ q . text ( part . value [ 1 ..-1 ] )
1362
+ end
1359
1363
end
1360
1364
end
1361
1365
q . breakable ( "" )
@@ -1450,10 +1454,17 @@ def to_json(*opts)
1450
1454
def qwords?
1451
1455
contents && contents . comments . empty? && contents . parts . length > 1 &&
1452
1456
contents . parts . all? do |part |
1453
- part . is_a? ( StringLiteral ) && part . comments . empty? &&
1454
- part . parts . length == 1 &&
1455
- part . parts . first . is_a? ( TStringContent ) &&
1456
- !part . parts . first . value . match? ( /[\s \[ \] \\ ]/ )
1457
+ case part
1458
+ when StringLiteral
1459
+ part . comments . empty? &&
1460
+ part . parts . length == 1 &&
1461
+ part . parts . first . is_a? ( TStringContent ) &&
1462
+ !part . parts . first . value . match? ( /[\s \[ \] \\ ]/ )
1463
+ when CHAR
1464
+ !part . value . match? ( /[\[ \] \\ ]/ )
1465
+ else
1466
+ false
1467
+ end
1457
1468
end
1458
1469
end
1459
1470
You can’t perform that action at this time.
0 commit comments