mirror of
https://github.com/pry/pry.git
synced 2022-11-09 12:35:05 -05:00
switch back to whitespace instead of ANSI
This commit is contained in:
parent
ca1b7b95b4
commit
66be4f1a6a
2 changed files with 8 additions and 6 deletions
|
@ -174,8 +174,10 @@ class Pry
|
|||
# the correct indentation. Mostly useful for fixing 'end'.
|
||||
#
|
||||
# @param [String] full_line The full line of input, including the prompt.
|
||||
# @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)
|
||||
def correct_indentation(full_line, overhang=0)
|
||||
if Readline.respond_to?(:get_screen_size)
|
||||
_, cols = Readline.get_screen_size
|
||||
lines = full_line.length / cols + 1
|
||||
|
@ -186,11 +188,11 @@ class Pry
|
|||
lines = 1
|
||||
end
|
||||
|
||||
move_up = "\e[#{lines}F"
|
||||
kill_line = "\e[0K"
|
||||
move_down = "\e[#{lines}E"
|
||||
move_up = "\e[#{lines}F"
|
||||
whitespace = ' ' * overhang
|
||||
move_down = "\e[#{lines}E"
|
||||
|
||||
"#{move_up}#{full_line}#{kill_line}#{move_down}"
|
||||
"#{move_up}#{full_line}#{whitespace}#{move_down}"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -314,7 +314,7 @@ class Pry
|
|||
val = @indent.indent(val)
|
||||
|
||||
if orig_val != val && output.tty? && Pry::Helpers::BaseHelpers.use_ansi_codes?
|
||||
output.print @indent.correct_indentation(current_prompt + val)
|
||||
output.print @indent.correct_indentation(current_prompt + val, orig_val.length - val.length)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue