def retrieve_line(eval_string, target)
@indent.reset if eval_string.empty?
current_prompt = select_prompt(eval_string, target)
completion_proc = Pry::InputCompleter.build_completion_proc(target,
instance_eval(&custom_completions))
indentation = Pry.config.auto_indent ? @indent.current_prefix : ''
begin
val = readline("#{current_prompt}#{indentation}", completion_proc)
rescue Interrupt
output.puts ""
eval_string.replace("")
return
end
if !val
output.puts ""
Pry.config.control_d_handler.call(eval_string, self)
return
end
if should_force_encoding?(eval_string, val)
eval_string.force_encoding(val.encoding)
end
if Pry.config.auto_indent && !input.is_a?(StringIO)
original_val = "#{indentation}#{val}"
indented_val = @indent.indent(val)
if output.tty? && Pry::Helpers::BaseHelpers.use_ansi_codes? && Pry.config.correct_indent
output.print @indent.correct_indentation(current_prompt, indented_val, original_val.length - indented_val.length)
output.flush
end
else
indented_val = val
end
begin
if !process_command(val, eval_string, target)
eval_string << "#{indented_val.rstrip}\n" unless val.empty?
end
ensure
Pry.history << indented_val unless input.is_a?(StringIO)
end
end