1
0
Fork 0
mirror of https://github.com/pry/pry.git synced 2022-11-09 12:35:05 -05:00

Don't colorize prompt

This commit is contained in:
Conrad Irwin 2012-04-02 00:31:22 -07:00
parent 0fbadb9f46
commit f84c7e0f8b
2 changed files with 6 additions and 4 deletions

View file

@ -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

View file

@ -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