diff --git a/lib/pry/code.rb b/lib/pry/code.rb index f58189eb..b99f9767 100644 --- a/lib/pry/code.rb +++ b/lib/pry/code.rb @@ -253,12 +253,7 @@ class Pry # @return [String] a formatted representation (based on the configuration of # the object). def to_s - print_to_output("", false) - end - - # @return [String] a (possibly highlighted) copy of the source code. - def highlighted - print_to_output("", true) + print_to_output("") end # Writes a formatted representation (based on the configuration of the @@ -266,7 +261,7 @@ class Pry def print_to_output(output, color=false) @lines.each do |loc| loc = loc.dup - loc.colorize(@code_type) if color + loc.colorize(@code_type) loc.add_line_number(max_lineno_width, color) if @with_line_numbers loc.add_marker(@marker_lineno) if @with_marker loc.indent(@indentation_num) if @with_indentation diff --git a/lib/pry/commands/cat/abstract_formatter.rb b/lib/pry/commands/cat/abstract_formatter.rb index c5546476..661f036b 100644 --- a/lib/pry/commands/cat/abstract_formatter.rb +++ b/lib/pry/commands/cat/abstract_formatter.rb @@ -8,7 +8,7 @@ class Pry def decorate(content) content.code_type = code_type content.between(*between_lines). - with_line_numbers(use_line_numbers?).highlighted + with_line_numbers(use_line_numbers?) end def code_type diff --git a/lib/pry/commands/show_source.rb b/lib/pry/commands/show_source.rb index f8e3a5b0..f3f069e4 100644 --- a/lib/pry/commands/show_source.rb +++ b/lib/pry/commands/show_source.rb @@ -40,7 +40,7 @@ class Pry # The source for code_object prepared for display. def content_for(code_object) Code.new(code_object.source, start_line_for(code_object)). - with_line_numbers(use_line_numbers?).highlighted + with_line_numbers(use_line_numbers?) end end diff --git a/lib/pry/commands/watch_expression.rb b/lib/pry/commands/watch_expression.rb index d93b7c72..52a88afd 100644 --- a/lib/pry/commands/watch_expression.rb +++ b/lib/pry/commands/watch_expression.rb @@ -88,7 +88,7 @@ class Pry def add_expression(arguments) expressions << Expression.new(_pry_, target, arg_string) - output.puts "Watching #{Code.new(arg_string).highlighted}" + output.puts "Watching #{Code.new(arg_string)}" end def add_hook diff --git a/lib/pry/commands/watch_expression/expression.rb b/lib/pry/commands/watch_expression/expression.rb index 514b95dd..a73b4014 100644 --- a/lib/pry/commands/watch_expression/expression.rb +++ b/lib/pry/commands/watch_expression/expression.rb @@ -6,7 +6,7 @@ class Pry def initialize(_pry_, target, source) @_pry_ = _pry_ @target = target - @source = Code.new(source).strip + @source = source.strip end def eval! @@ -15,7 +15,7 @@ class Pry end def to_s - "#{Code.new(source).highlighted.strip} => #{value}" + "#{Code.new(source).strip} => #{value}" end # Has the value of the expression changed? diff --git a/lib/pry/commands/whereami.rb b/lib/pry/commands/whereami.rb index ac701645..695ecc90 100644 --- a/lib/pry/commands/whereami.rb +++ b/lib/pry/commands/whereami.rb @@ -89,7 +89,7 @@ class Pry set_file_and_dir_locals(@file) out = "\n#{text.bold('From:')} #{location}:\n\n" << - code.with_line_numbers(use_line_numbers?).with_marker(marker).highlighted << "\n" + code.with_line_numbers(use_line_numbers?).with_marker(marker) << "\n" _pry_.pager.page out end