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

Don't output whereami at all unless there is code. Fixes binding.pry on (main).

This commit is contained in:
Jordon Bedwell 2012-04-01 03:02:37 -05:00
parent 07095ceccd
commit 053d91051a

View file

@ -22,12 +22,14 @@ class Pry
method = Pry::Method.from_binding(target) method = Pry::Method.from_binding(target)
method_description = method ? " in #{method.name_with_owner}" : "" method_description = method ? " in #{method.name_with_owner}" : ""
output.puts "\n#{text.bold('From:')} #{file} @ line #{line_num}#{method_description}:\n\n"
code = Pry::Code.from_file(file).around(line_num, i_num) code = Pry::Code.from_file(file).around(line_num, i_num)
if !code.empty?
output.puts "\n#{text.bold('From:')} #{file} @ line #{line_num}#{method_description}:\n\n"
output.puts code.with_line_numbers.with_marker(line_num) output.puts code.with_line_numbers.with_marker(line_num)
output.puts output.puts
end end
end
create_command "pry-backtrace", "Show the backtrace for the Pry session." do create_command "pry-backtrace", "Show the backtrace for the Pry session." do
banner <<-BANNER banner <<-BANNER