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

Move should_print? check into show_result

This commit is contained in:
Ryan Fitzgerald 2012-08-07 21:03:36 -07:00
parent 331f47b0cf
commit 9d5ae76fd4

View file

@ -249,7 +249,7 @@ class Pry
target = Pry.binding_for(target) target = Pry.binding_for(target)
result = re(target) result = re(target)
show_result(result) if should_print? show_result(result)
end end
# Perform a read-eval # Perform a read-eval
@ -327,8 +327,10 @@ class Pry
def show_result(result) def show_result(result)
if last_result_is_exception? if last_result_is_exception?
exception_handler.call(output, result, self) exception_handler.call(output, result, self)
else elsif should_print?
print.call(output, result) print.call(output, result)
else
# nothin'
end end
rescue RescuableException => e rescue RescuableException => e
# Being uber-paranoid here, given that this exception arose because we couldn't # Being uber-paranoid here, given that this exception arose because we couldn't
@ -614,11 +616,10 @@ class Pry
end end
# Whether the print proc should be invoked. # Whether the print proc should be invoked.
# Currently only invoked if the output is not suppressed OR the last result # Currently only invoked if the output is not suppressed.
# is an exception regardless of suppression.
# @return [Boolean] Whether the print proc should be invoked. # @return [Boolean] Whether the print proc should be invoked.
def should_print? def should_print?
!@suppress_output || last_result_is_exception? !@suppress_output
end end
# Returns the appropriate prompt to use. # Returns the appropriate prompt to use.