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

Somewhat cleaner history-recording logic

This commit is contained in:
Ryan Fitzgerald 2012-08-30 00:53:40 -07:00
parent 124c24c573
commit 77600d3bd5

View file

@ -407,20 +407,16 @@ class Pry
indented_val = val indented_val = val
end end
# Check this before processing the line, because a command might change
# Pry's input.
interactive = !input.is_a?(StringIO)
begin begin
if !process_command(val, eval_string, target) if !process_command(val, eval_string, target)
eval_string << "#{indented_val.chomp}\n" unless val.empty? eval_string << "#{indented_val.chomp}\n" unless val.empty?
end end
ensure ensure
if input.is_a?(StringIO) Pry.history << indented_val if interactive
# Add to history only those values that were typed by a user. Ignore
# programmatically created ones.
unless input.string.include?(indented_val)
Pry.history << indented_val.chomp
end
else
Pry.history << indented_val
end
end end
end end