Skip to content

Commit

Permalink
Pass prompt into read from repl
Browse files Browse the repository at this point in the history
  • Loading branch information
rf- committed Jan 28, 2013
1 parent c2edd8d commit b6f5dd0
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions lib/pry/repl.rb
Expand Up @@ -65,7 +65,7 @@ def prologue
# thrown with it.
def repl
loop do
case val = read
case val = read(pry.select_prompt)
when :control_c
output.puts ""
pry.reset_eval_string
Expand All @@ -86,16 +86,17 @@ def epilogue
end

# Read a line of input from the user.
# @param [String] prompt The prompt to use for input.
# @return [String] The line entered by the user.
# @return [nil] On `<Ctrl-D>`.
# @return [:control_c] On `<Ctrl+C>`.
# @return [:no_more_input] On EOF.
def read
def read(prompt)
@indent.reset if pry.eval_string.empty?
current_prompt = pry.select_prompt

indentation = Pry.config.auto_indent ? @indent.current_prefix : ''

val = read_line("#{current_prompt}#{indentation}")
val = read_line("#{prompt}#{indentation}")

# Return nil for EOF, :no_more_input for error, or :control_c for <Ctrl-C>
return val unless String === val
Expand All @@ -106,7 +107,7 @@ def read

if output.tty? && @indent.should_correct_indentation?
output.print @indent.correct_indentation(
current_prompt, indented_val,
prompt, indented_val,
original_val.length - indented_val.length
)
output.flush
Expand Down

0 comments on commit b6f5dd0

Please sign in to comment.