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
10 changes: 6 additions & 4 deletions lib/ruby_lsp/requests/completion_resolve.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,12 @@ def perform
"[Learn more about guessed types](#{GUESSED_TYPES_URL})"
end

@item[:documentation] = Interface::MarkupContent.new(
kind: "markdown",
value: markdown_from_index_entries(label, entries, MAX_DOCUMENTATION_ENTRIES, extra_links: extra_links),
)
unless @item[:kind] == Constant::CompletionItemKind::FILE
@item[:documentation] = Interface::MarkupContent.new(
kind: "markdown",
value: markdown_from_index_entries(label, entries, MAX_DOCUMENTATION_ENTRIES, extra_links: extra_links),
)
end

@item
end
Expand Down
19 changes: 19 additions & 0 deletions test/requests/completion_resolve_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -207,4 +207,23 @@ def foo
assert_match("[Read more](#{RubyLsp::STATIC_DOCS_PATH}/yield.md)", contents)
end
end

def test_resolve_for_require_completion
source = +<<~RUBY
require ""
RUBY

with_server(source, stub_no_typechecker: true) do |server, _uri|
existing_item = {
label: "foo",
kind: RubyLsp::Constant::CompletionItemKind::FILE,
data: {},
}

server.process_message(id: 1, method: "completionItem/resolve", params: existing_item)

result = server.pop_response.response
assert_nil(result[:documentation])
end
end
end