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

Strip ansi codes from prompt before measuring [Issue #493]

This commit is contained in:
Conrad Irwin 2013-02-13 10:42:43 -08:00
parent 293aafd4ea
commit 731d0cf20d

View file

@ -384,13 +384,13 @@ class Pry
# @return [String]
def correct_indentation(prompt, code, overhang=0)
prompt = prompt.delete("\001\002")
full_line = prompt + code
line_to_measure = Pry::Helpers::Text.strip_color(prompt) + code
whitespace = ' ' * overhang
_, cols = Terminal.screen_size
cols = cols.to_i
lines = cols != 0 ? (full_line.length / cols + 1) : 1
lines = cols != 0 ? (line_to_measure.length / cols + 1) : 1
if Pry::Helpers::BaseHelpers.windows_ansi?
move_up = "\e[#{lines}F"