mirror of
https://github.com/pry/pry.git
synced 2022-11-09 12:35:05 -05:00
singleline rescue should not change indentation.
This commit is contained in:
parent
f117fded1c
commit
4156c4498c
2 changed files with 12 additions and 0 deletions
|
@ -225,6 +225,8 @@ class Pry
|
|||
|
||||
seen_for_at << add_after if OPTIONAL_DO_TOKENS.include?(token)
|
||||
|
||||
next if is_singleline_if
|
||||
|
||||
if kind == :delimiter
|
||||
track_delimiter(token)
|
||||
elsif OPEN_TOKENS.keys.include?(token) && !is_optional_do && !is_singleline_if
|
||||
|
|
|
@ -243,6 +243,16 @@ OUTPUT
|
|||
expect(@indent.indent(input)).to eq output
|
||||
end
|
||||
|
||||
it "should not indent single-line rescue" do
|
||||
input = <<INPUT.strip
|
||||
def test
|
||||
puts "something" rescue "whatever"
|
||||
end
|
||||
INPUT
|
||||
|
||||
expect(@indent.indent(input)).to eq input
|
||||
end
|
||||
|
||||
it "should not indent inside strings" do
|
||||
expect(@indent.indent(%(def a\n"foo\nbar"\n end))).to eq %(def a\n "foo\nbar"\nend)
|
||||
expect(@indent.indent(%(def a\nputs %w(foo\nbar), 'foo\nbar'\n end))).to eq %(def a\n puts %w(foo\nbar), 'foo\nbar'\nend)
|
||||
|
|
Loading…
Add table
Reference in a new issue