From f84c7e0f8b8be99e4d0a0b70cc0360671d208fc3 Mon Sep 17 00:00:00 2001 From: Conrad Irwin Date: Mon, 2 Apr 2012 00:31:22 -0700 Subject: [PATCH] Don't colorize prompt --- lib/pry/indent.rb | 8 +++++--- lib/pry/pry_instance.rb | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/pry/indent.rb b/lib/pry/indent.rb index 94198c73..a084451b 100644 --- a/lib/pry/indent.rb +++ b/lib/pry/indent.rb @@ -187,11 +187,13 @@ class Pry # Return a string which, when printed, will rewrite the previous line with # the correct indentation. Mostly useful for fixing 'end'. # - # @param [String] full_line The full line of input, including the prompt. + # @param [String] prompt The user's prompt + # @param [String] code The code the user just typed in. # @param [Fixnum] overhang (0) The number of chars to erase afterwards (i.e., # the difference in length between the old line and the new one). # @return [String] - def correct_indentation(full_line, overhang=0) + def correct_indentation(prompt, code, overhang=0) + full_line = prompt + code if Readline.respond_to?(:get_screen_size) _, cols = Readline.get_screen_size lines = full_line.length / cols + 1 @@ -211,7 +213,7 @@ class Pry end whitespace = ' ' * overhang - "#{move_up}#{CodeRay.scan(full_line, :ruby).term}#{whitespace}#{move_down}" + "#{move_up}#{prompt}#{CodeRay.scan(code, :ruby).term}#{whitespace}#{move_down}" end end end diff --git a/lib/pry/pry_instance.rb b/lib/pry/pry_instance.rb index 19720fea..132eaf34 100644 --- a/lib/pry/pry_instance.rb +++ b/lib/pry/pry_instance.rb @@ -378,7 +378,7 @@ class Pry 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.print @indent.correct_indentation(current_prompt, indented_val, original_val.length - indented_val.length) output.flush end else