Fix off-by-one error in Method#source_range

This commit is contained in:
Conrad Irwin 2012-04-13 22:26:18 -07:00
parent e0a28bb5f8
commit 71a30216fd
2 changed files with 2 additions and 2 deletions

View File

@ -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__")

View File

@ -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`,