# File lib/pry/helpers/command_helpers.rb, line 74 def unindent(text, left_padding = 0) # Empty blank lines text = text.sub(/^[ \t]+$/, '') # Find the longest common whitespace to all indented lines # Ignore lines containing just -- or ++ as these seem to be used by # comment authors as delimeters. margin = text.scan(/^[ \t]*(?!--\n|\+\+\n)(?=[^ \t\n])/).inject do |current_margin, next_indent| if next_indent.start_with?(current_margin) current_margin elsif current_margin.start_with?(next_indent) next_indent else "" end end text.gsub(/^#{margin}/, ' ' * left_padding) end