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:
parent
b96a26c094
commit
98a063019a
3 changed files with 6 additions and 1 deletions
|
@ -134,6 +134,10 @@ class Pry
|
||||||
# @return [Boolean] Whether or not code should be indented
|
# @return [Boolean] Whether or not code should be indented
|
||||||
# using Pry::Indent.
|
# using Pry::Indent.
|
||||||
attr_accessor :auto_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
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -191,6 +191,7 @@ class Pry
|
||||||
config.disable_auto_reload = false
|
config.disable_auto_reload = false
|
||||||
config.command_prefix = ""
|
config.command_prefix = ""
|
||||||
config.auto_indent = true
|
config.auto_indent = true
|
||||||
|
config.correct_indent = true
|
||||||
|
|
||||||
config.plugins ||= OpenStruct.new
|
config.plugins ||= OpenStruct.new
|
||||||
config.plugins.enabled = true
|
config.plugins.enabled = true
|
||||||
|
|
|
@ -321,7 +321,7 @@ class Pry
|
||||||
orig_val = "#{indentation}#{val}"
|
orig_val = "#{indentation}#{val}"
|
||||||
val = @indent.indent(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)
|
output.print @indent.correct_indentation(current_prompt + val, orig_val.length - val.length)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Reference in a new issue