singleline rescue should not change indentation.

This commit is contained in:
egwspiti 2015-07-22 21:26:08 +03:00
parent f117fded1c
commit 4156c4498c
2 changed files with 12 additions and 0 deletions

View File

@ -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

View File

@ -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)