Skip to content

Commit 00e4711

Browse files
committed
Fix Location#end_column
1 parent 0a11ec5 commit 00e4711

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

lib/yarp.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ def start_column
9595
# The column number in bytes where this location ends from the start of the
9696
# line.
9797
def end_column
98-
source.column(end_offset - 1)
98+
source.column(end_offset)
9999
end
100100

101101
def deconstruct_keys(keys)

test/yarp/location_test.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -817,6 +817,14 @@ def assert_location(kind, source, expected = 0...source.length)
817817
node = result.value.statements.body.last
818818
node = yield node if block_given?
819819

820+
if expected.begin == 0
821+
assert_equal 0, node.location.start_column
822+
end
823+
824+
if expected.end == source.length
825+
assert_equal source.split("\n").last.length, node.location.end_column
826+
end
827+
820828
assert_kind_of kind, node
821829
assert_equal expected.begin, node.location.start_offset
822830
assert_equal expected.end, node.location.end_offset

0 commit comments

Comments
 (0)