1
0
Fork 0
mirror of https://github.com/pry/pry.git synced 2022-11-09 12:35:05 -05:00

Don't clobber _ex_ on typoes

This commit is contained in:
Conrad Irwin 2012-01-12 23:21:21 -08:00
parent d2f5725537
commit c74d240d0a
2 changed files with 11 additions and 1 deletions

View file

@ -257,7 +257,12 @@ class Pry
output.puts "Error: #{e.message}" output.puts "Error: #{e.message}"
end end
break if complete_expression?(eval_string) begin
break if complete_expression?(eval_string)
rescue SyntaxError => e
output.puts "SyntaxError: #{e.message.sub(/.*syntax error, */m, '')}"
eval_string = ""
end
end end
@suppress_output = true if eval_string =~ /;\Z/ || eval_string.empty? @suppress_output = true if eval_string =~ /;\Z/ || eval_string.empty?

View file

@ -55,4 +55,9 @@ describe Pry do
pry = Pry.new pry = Pry.new
pry.complete_expression?("puts 1, 2,\n3").should == true pry.complete_expression?("puts 1, 2,\n3").should == true
end end
it "should not clobber _ex_ on a SyntaxError in the repl" do
mock_pry("raise RuntimeError, 'foo';", "puts foo)", "_ex_.is_a?(RuntimeError)").should =~ /^RuntimeError.*\nSyntaxError.*\n=> true/m
end
end end