Skip to content

Commit 807fd07

Browse files
[clangd] Handle variable templates consistently with class templates in code completion (#85740)
The option --function-arg-placeholders=0 results in placeholders being omitted for class template argument lists. This patch extends the same treatment to variable template argument lists. Fixes clangd/clangd#1976
1 parent d538c56 commit 807fd07

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

clang-tools-extra/clangd/CodeComplete.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -619,7 +619,8 @@ struct CodeCompletionBuilder {
619619
}
620620
// 'CompletionItemKind::Interface' matches template type aliases.
621621
if (Completion.Kind == CompletionItemKind::Interface ||
622-
Completion.Kind == CompletionItemKind::Class) {
622+
Completion.Kind == CompletionItemKind::Class ||
623+
Completion.Kind == CompletionItemKind::Variable) {
623624
if (Snippet->front() != '<')
624625
return *Snippet; // Not an arg snippet?
625626

clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2648,12 +2648,15 @@ TEST(CompletionTest, CompletionFunctionArgsDisabled) {
26482648
class foo_class{};
26492649
template <class T>
26502650
using foo_alias = T**;
2651+
template <class T>
2652+
T foo_var = T{};
26512653
void f() { foo_^ })cpp",
26522654
{}, Opts);
26532655
EXPECT_THAT(
26542656
Results.Completions,
26552657
UnorderedElementsAre(AllOf(named("foo_class"), snippetSuffix("<$0>")),
2656-
AllOf(named("foo_alias"), snippetSuffix("<$0>"))));
2658+
AllOf(named("foo_alias"), snippetSuffix("<$0>")),
2659+
AllOf(named("foo_var"), snippetSuffix("<$0>"))));
26572660
}
26582661
{
26592662
auto Results = completions(

0 commit comments

Comments
 (0)