mirror of
https://github.com/pry/pry.git
synced 2022-11-09 12:35:05 -05:00
move code to correct indentation into a method on Pry::Indent
This commit is contained in:
parent
029d192e95
commit
971223d94a
2 changed files with 12 additions and 7 deletions
|
@ -132,5 +132,16 @@ class Pry
|
|||
|
||||
return output.gsub!(/\s+$/, '')
|
||||
end
|
||||
|
||||
|
||||
# Fix the indentation for closing tags (notably 'end').
|
||||
# @param [String] full_line The full line of input, including the prompt.
|
||||
def correct_indentation(full_line)
|
||||
# The whitespace is used to "clear" the current line so existing
|
||||
# characters don't show up.
|
||||
spaces = ' ' * full_line.length
|
||||
|
||||
$stdout.write(`tput sc` + `tput cuu1` + full_line + spaces + `tput rc`)
|
||||
end
|
||||
end # Indent
|
||||
end # Pry
|
||||
|
|
|
@ -311,13 +311,7 @@ class Pry
|
|||
# Refresh the current line. This uses tput and since that doesn't work
|
||||
# on Windows this process will not be executed on that platform.
|
||||
if !Kernel.const_defined?(:Win32) && input == Readline
|
||||
prompt = current_prompt + val
|
||||
|
||||
# The whitespace is used to "clear" the current line so existing
|
||||
# characters don't show up.
|
||||
spaces = ' ' * prompt.length
|
||||
|
||||
$stdout.write(`tput sc` + `tput cuu1` + prompt + spaces + `tput rc`)
|
||||
@indent.correct_indentation(current_prompt + val)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue