Skip to content

Commit

Permalink
Fix Location#end_column
Browse files Browse the repository at this point in the history
  • Loading branch information
andyw8 committed Sep 6, 2023
1 parent 0a11ec5 commit 00e4711
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/yarp.rb
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def start_column
# The column number in bytes where this location ends from the start of the
# line.
def end_column
source.column(end_offset - 1)
source.column(end_offset)
end

def deconstruct_keys(keys)
Expand Down
8 changes: 8 additions & 0 deletions test/yarp/location_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -817,6 +817,14 @@ def assert_location(kind, source, expected = 0...source.length)
node = result.value.statements.body.last
node = yield node if block_given?

if expected.begin == 0
assert_equal 0, node.location.start_column
end

if expected.end == source.length
assert_equal source.split("\n").last.length, node.location.end_column
end

assert_kind_of kind, node
assert_equal expected.begin, node.location.start_offset
assert_equal expected.end, node.location.end_offset
Expand Down

0 comments on commit 00e4711

Please sign in to comment.