From 98a063019a381384f4eaee33a96a71716665f043 Mon Sep 17 00:00:00 2001 From: Ryan Fitzgerald Date: Thu, 27 Oct 2011 23:57:01 -0700 Subject: [PATCH] add correct_indent option --- lib/pry/config.rb | 4 ++++ lib/pry/pry_class.rb | 1 + lib/pry/pry_instance.rb | 2 +- 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/pry/config.rb b/lib/pry/config.rb index 7561d4aa..b953f309 100644 --- a/lib/pry/config.rb +++ b/lib/pry/config.rb @@ -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 diff --git a/lib/pry/pry_class.rb b/lib/pry/pry_class.rb index f19c5f82..3715e500 100644 --- a/lib/pry/pry_class.rb +++ b/lib/pry/pry_class.rb @@ -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 diff --git a/lib/pry/pry_instance.rb b/lib/pry/pry_instance.rb index b1026d9e..56232a46 100644 --- a/lib/pry/pry_instance.rb +++ b/lib/pry/pry_instance.rb @@ -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