diff --git a/lib/yarp.rb b/lib/yarp.rb index 0dab1515fc3..769b149bcab 100644 --- a/lib/yarp.rb +++ b/lib/yarp.rb @@ -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) diff --git a/test/yarp/location_test.rb b/test/yarp/location_test.rb index 4509fc0cf5d..d86afb0b3bb 100644 --- a/test/yarp/location_test.rb +++ b/test/yarp/location_test.rb @@ -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