From af5bfdde387a70265433e7506e1ea48510aad3fe Mon Sep 17 00:00:00 2001 From: Vinicius Stock Date: Wed, 24 Dec 2025 11:08:42 -0300 Subject: [PATCH] Skip adding documentation for require completions --- lib/ruby_lsp/requests/completion_resolve.rb | 10 ++++++---- test/requests/completion_resolve_test.rb | 19 +++++++++++++++++++ 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/lib/ruby_lsp/requests/completion_resolve.rb b/lib/ruby_lsp/requests/completion_resolve.rb index 3e503bf413..25ae979d48 100644 --- a/lib/ruby_lsp/requests/completion_resolve.rb +++ b/lib/ruby_lsp/requests/completion_resolve.rb @@ -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 diff --git a/test/requests/completion_resolve_test.rb b/test/requests/completion_resolve_test.rb index 3a430069c5..e1effb6f8f 100644 --- a/test/requests/completion_resolve_test.rb +++ b/test/requests/completion_resolve_test.rb @@ -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