diff --git a/lib/pry/commands/cat/file_formatter.rb b/lib/pry/commands/cat/file_formatter.rb index 02b32f6f..c60c55e8 100644 --- a/lib/pry/commands/cat/file_formatter.rb +++ b/lib/pry/commands/cat/file_formatter.rb @@ -11,6 +11,15 @@ class Pry @_pry_ = _pry_ end + def format + raise CommandError, "Must provide a filename, --in, or --ex." if !file_with_embedded_line + + set_file_and_dir_locals(file_name, _pry_, _pry_.current_context) + decorate(Pry::Code.from_file(file_name)) + end + + private + def file_and_line file_name, line_num = file_with_embedded_line.split(':') @@ -29,15 +38,6 @@ class Pry Pry.config.default_window_size || 7 end - def format - raise CommandError, "Must provide a filename, --in, or --ex." if !file_with_embedded_line - - set_file_and_dir_locals(file_name, _pry_, _pry_.current_context) - decorate(Pry::Code.from_file(file_name)) - end - - private - def decorate(content) line_number ? super.around(line_number, code_window_size) : super end diff --git a/lib/pry/commands/cat/input_expression_formatter.rb b/lib/pry/commands/cat/input_expression_formatter.rb index 674cd061..3650ede8 100644 --- a/lib/pry/commands/cat/input_expression_formatter.rb +++ b/lib/pry/commands/cat/input_expression_formatter.rb @@ -25,6 +25,7 @@ class Pry end private + def selected_input_items input_expressions[normalized_expression_range] || [] end