Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/ruby_language_server/code_file.rb
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def tags
{
name:,
kind: SYMBOL_KIND[:constant],
location: Location.hash(uri, variable.line - 1, variable.column),
location: Location.hash(uri, variable.line, variable.column),
containerName: variable.scope.name
}
end
Expand Down
12 changes: 12 additions & 0 deletions spec/lib/ruby_language_server/code_file_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,18 @@ def code_file(text)
assert_equal(expected_initialize_range, initialize_tag[:location][:range])
assert_equal(expected_foo_method_range, foo_method_tag[:location][:range])
end

it 'should have correct start and end lines for constants' do
tag = cf.tags.detect { |t| t[:name] == 'FOO_CONSTANT' }

# The constant is on line 9 (1-indexed), which should be line 8 (0-indexed) in LSP
# FOO_CONSTANT = 1 is on line 9 of the source
expected_range = {
start: { line: 8, character: 2 },
end: { line: 8, character: 2 }
}
assert_equal(expected_range, tag[:location][:range])
end
end
end
end
Expand Down