mirror of
https://github.com/pry/pry.git
synced 2022-11-09 12:35:05 -05:00
Always start the prompt in the first column (fix #551)
This commit is contained in:
parent
b61db31b39
commit
7af3660042
2 changed files with 15 additions and 9 deletions
|
@ -333,19 +333,25 @@ class Pry
|
|||
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))
|
||||
# If necessary, make sure the prompt starts in the first column (issue #551)
|
||||
if Pry::Helpers::BaseHelpers.use_ansi_codes? && Pry.config.correct_indent
|
||||
column_reset = "\e[0G"
|
||||
end
|
||||
|
||||
current_prompt = select_prompt(eval_string, target)
|
||||
|
||||
indentation = Pry.config.auto_indent ? @indent.current_prefix : ''
|
||||
|
||||
begin
|
||||
val = readline("#{current_prompt}#{indentation}", completion_proc)
|
||||
completion_proc = Pry::InputCompleter.build_completion_proc(
|
||||
target, instance_eval(&custom_completions))
|
||||
|
||||
# Handle <Ctrl+C> like Bash, empty the current input buffer but do not quit.
|
||||
# This is only for ruby-1.9; other versions of ruby do not let you send Interrupt
|
||||
# from within Readline.
|
||||
begin
|
||||
full_prompt = "#{column_reset}#{current_prompt}#{indentation}"
|
||||
val = readline(full_prompt, completion_proc)
|
||||
|
||||
# Handle <Ctrl-C> like Bash: empty the current input buffer but do not
|
||||
# quit. This is only for Ruby 1.9; other versions of Ruby do not let you
|
||||
# send Interrupt from within Readline.
|
||||
rescue Interrupt => e
|
||||
output.puts ""
|
||||
eval_string.replace("")
|
||||
|
|
|
@ -37,7 +37,7 @@ describe "test Pry defaults" do
|
|||
end.new
|
||||
|
||||
Pry.start(self, :input => arity_one_input, :output => Pry::NullOutput)
|
||||
arity_one_input.prompt.should == Pry.prompt.call
|
||||
arity_one_input.prompt.should.include? Pry.prompt.call
|
||||
end
|
||||
|
||||
it 'should not pass in the prompt if the arity is 0' do
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue