Skip to content

DefNode#location is incorrect for an endless method in some cases #229

@andyw8

Description

@andyw8

Endless method followed by a single newline (correct):

irb(main):013:0> SyntaxTree.parse("def foo = 1\n").child_nodes.first.child_nodes.first.location
=> #<SyntaxTree::Location:0x0000000107852f48 @end_char=12, @end_column=12, @end_line=1, @start_char=0, @start_column=0, @start_line=1>

Endless method followed by multiple newlines (incorrect):

irb(main):014:0> SyntaxTree.parse("def foo = 1\n\n").child_nodes.first.child_nodes.first.location
=> #<SyntaxTree::Location:0x0000000107ff0818 @end_char=1, @end_column=1, @end_line=1, @start_char=0, @start_column=0, @start_line=1>

Shopify/ruby-lsp#400

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