Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 29d675f

Browse files
committed
Explicitly handle ?" so that it formats properly.
1 parent 8c5a72a commit 29d675f

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) a
3535
- Keep block `If`, `Unless`, `While`, and `Until` forms if there is an assignment in the predicate.
3636
- Force using braces if the block is within the predicate of a conditional or loop.
3737
- Allow for the possibility that `CommandCall` nodes might not have arguments.
38+
- Explicitly handle `?"` so that it formats properly.
39+
- Check that a block is within the predicate in a more relaxed way.
3840

3941
### Removed
4042

lib/syntax_tree.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -482,7 +482,7 @@ def format(q)
482482
q.text(value)
483483
else
484484
q.text(q.quote)
485-
q.text(value[1])
485+
q.text(value[1] == "\"" ? "\\\"" : value[1])
486486
q.text(q.quote)
487487
end
488488
end
@@ -2769,8 +2769,8 @@ def forced_do_end_bounds?(q)
27692769
# If we're the predicate of a loop or conditional, then we're going to have
27702770
# to go with the {..} bounds.
27712771
def forced_brace_bounds?(q)
2772-
parent = q.parents.to_a[1]
2773-
[If, IfMod, Unless, UnlessMod, While, WhileMod, Until, UntilMod].include?(parent.class) && node == parent.predicate.block
2772+
parent, grandparent, = q.parents.to_a
2773+
[If, IfMod, Unless, UnlessMod, While, WhileMod, Until, UntilMod].include?(grandparent.class) && parent == grandparent.predicate
27742774
end
27752775

27762776
def format_break(q, opening, closing)

0 commit comments

Comments
 (0)