From 71a30216fdae8fd720fc40b0d1304fac19e839d2 Mon Sep 17 00:00:00 2001 From: Conrad Irwin Date: Fri, 13 Apr 2012 22:26:18 -0700 Subject: [PATCH] Fix off-by-one error in Method#source_range --- lib/pry/default_commands/context.rb | 2 +- lib/pry/method.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/pry/default_commands/context.rb b/lib/pry/default_commands/context.rb index 61dfa1b7..9f2b6535 100644 --- a/lib/pry/default_commands/context.rb +++ b/lib/pry/default_commands/context.rb @@ -24,7 +24,7 @@ class Pry if show_method? file = @method.source_file start = @method.source_range.begin - finish = @method.source_range.end - 1 + finish = @method.source_range.end marker = target.eval("__LINE__") else file = target.eval("__FILE__") diff --git a/lib/pry/method.rb b/lib/pry/method.rb index 3cd4150d..21290651 100644 --- a/lib/pry/method.rb +++ b/lib/pry/method.rb @@ -317,7 +317,7 @@ class Pry # @return [Range, nil] The range of lines in `source_file` which contain # the method's definition, or `nil` if that information is unavailable. def source_range - source_location.nil? ? nil : (source_line)...(source_line + source.lines.count) + source_location.nil? ? nil : (source_line)..(source_line + source.lines.count - 1) end # @return [Symbol] The visibility of the method. May be `:public`,