diff options
author | Ryan Fitzgerald <rwfitzge@gmail.com> | 2013-01-09 00:34:24 -0800 |
---|---|---|
committer | Ryan Fitzgerald <rwfitzge@gmail.com> | 2013-01-27 21:32:48 -0800 |
commit | 7dc91136f6609d4a3231db7cca58568fb3a60d65 (patch) | |
tree | f9feeb1dff295bf1a127eaa7e4207d15a87a0599 | |
parent | ee46e93d293dbc699f9ed50367b37ddd93591b6c (diff) | |
download | pry-wip.refactor.repl.tar.gz |
Minor refactoring of #replwip.refactor.repl
-rw-r--r-- | lib/pry/repl.rb | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/lib/pry/repl.rb b/lib/pry/repl.rb index 458457c1..8256c1f2 100644 --- a/lib/pry/repl.rb +++ b/lib/pry/repl.rb @@ -65,20 +65,25 @@ class Pry # thrown with it. def repl loop do - case val = read(pry.select_prompt) + case line = read(pry.select_prompt) when :control_c - output.puts "" + advance_cursor pry.reset_eval_string when :no_more_input - output.puts "" if output.tty? + advance_cursor break else - output.puts "" if val.nil? && output.tty? - return pry.exit_value unless pry.eval(val) + advance_cursor if line.nil? + return pry.exit_value unless pry.eval(line) end end end + # Print an empty line if the output is a TTY. + def advance_cursor + output.puts "" if output.tty? + end + # Clean up after the repl session. # @return [void] def epilogue |