Skip to content

Position of RBS::Location should be byte length #1814

@ksss

Description

@ksss

I'm developing a tool using RBS.
And I'm trying to load RBS files using RBS::MethodType#location and display them with colors.

During development, a problem occurred where the display is off by one character only in core/math.rbs.

In core/math.rbs, the character π is used in the documentation, which is a 2 byte character.

Upon investigation, it appears that the positions in Location are recorded not in byte size but in the number of UTF-8 characters.

# Whether the comment is `π` or `p`, the class location has not changed.

::RBS::Parser.parse_signature("#π\nclass Foo\nend")[2][0].location.start_pos
#=> 3
::RBS::Parser.parse_signature("#p\nclass Foo\nend")[2][0].location.start_pos
#=> 3

Recording the position in bytesize would make it more convenient for reading with methods like IO#read, so I believe it should be recorded in bytesize.

What do you think?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions