From 47fb992adf04f6fe61bc70fee2f051e821d49d92 Mon Sep 17 00:00:00 2001 From: Vinicius Stock Date: Thu, 11 Jan 2024 09:59:24 -0300 Subject: [PATCH] Show method parameters as completion details (#1294) --- lib/ruby_lsp/requests/completion.rb | 1 + test/requests/completion_test.rb | 1 + 2 files changed, 2 insertions(+) diff --git a/lib/ruby_lsp/requests/completion.rb b/lib/ruby_lsp/requests/completion.rb index 019e3295d..ffd4c9e53 100644 --- a/lib/ruby_lsp/requests/completion.rb +++ b/lib/ruby_lsp/requests/completion.rb @@ -178,6 +178,7 @@ def build_method_completion(entry, node) text_edit: Interface::TextEdit.new(range: range_from_node(node), new_text: name), kind: Constant::CompletionItemKind::METHOD, label_details: Interface::CompletionItemLabelDetails.new( + detail: "(#{entry.parameters.map(&:decorated_name).join(", ")})", description: entry.file_name, ), documentation: markdown_from_index_entries(name, entry), diff --git a/test/requests/completion_test.rb b/test/requests/completion_test.rb index 8e1badd39..f7df5ef3c 100644 --- a/test/requests/completion_test.rb +++ b/test/requests/completion_test.rb @@ -494,6 +494,7 @@ def process assert_equal(["bar", "baz"], result.map(&:label)) assert_equal(["bar", "baz"], result.map(&:filter_text)) assert_equal(["bar", "baz"], result.map { |completion| completion.text_edit.new_text }) + assert_equal(["(a, b)", "(c, d)"], result.map { |completion| completion.label_details.detail }) end def test_completion_for_methods_named_with_uppercase_characters