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

add correct_indent option

This commit is contained in:
Ryan Fitzgerald 2011-10-27 23:57:01 -07:00
parent b96a26c094
commit 98a063019a
3 changed files with 6 additions and 1 deletions

View file

@ -134,6 +134,10 @@ class Pry
# @return [Boolean] Whether or not code should be indented
# using Pry::Indent.
attr_accessor :auto_indent
# @return [Boolean] Whether or not indentation should be corrected
# after hitting enter. This feature is not supported by all terminals.
attr_accessor :correct_indent
end
end

View file

@ -191,6 +191,7 @@ class Pry
config.disable_auto_reload = false
config.command_prefix = ""
config.auto_indent = true
config.correct_indent = true
config.plugins ||= OpenStruct.new
config.plugins.enabled = true

View file

@ -321,7 +321,7 @@ class Pry
orig_val = "#{indentation}#{val}"
val = @indent.indent(val)
if orig_val != val && output.tty? && Pry::Helpers::BaseHelpers.use_ansi_codes?
if orig_val != val && output.tty? && Pry::Helpers::BaseHelpers.use_ansi_codes? && Pry.config.correct_indent
output.print @indent.correct_indentation(current_prompt + val, orig_val.length - val.length)
end
end