Skip to content

Commit

Permalink
repl: try setting the readline output on carriage return
Browse files Browse the repository at this point in the history
If the first "input" is a StringIO, so the old approach never sets the
realine output, so we have to check every time.
  • Loading branch information
kyrylo committed Mar 2, 2015
1 parent e92ac92 commit 159254c
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions lib/pry/repl.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,6 @@ def initialize(pry, options = {})
if options[:target]
@pry.push_binding options[:target]
end

if readline_available? && piping?
Readline.output = File.open('/dev/tty', 'w')
end
end

# Start the read-eval-print loop.
Expand Down Expand Up @@ -184,6 +180,7 @@ def read_line(current_prompt)
end

if readline_available?
set_readline_output
input_readline(current_prompt, false) # false since we'll add it manually
elsif coolline_available?
input_readline(current_prompt)
Expand Down Expand Up @@ -222,5 +219,11 @@ def coolline_available?
def piping?
!$stdout.tty? && $stdin.tty? && !Pry::Helpers::BaseHelpers.windows?
end

def set_readline_output
@readline_output ||= if piping?
Readline.output = File.open('/dev/tty', 'w')
end
end
end
end

0 comments on commit 159254c

Please sign in to comment.