Code completion overload folding

What do we think about bundling overloaded functions into one completion item, vs clangd’s current behavior of providing each overload of a function as a separate completion item?

Off the top of my head, bundling pros:

  • less noise
  • present more diverse results
    Bundling cons:
  • lose the signature
  • complicated interactions with e.g. include insertion

My own feeling is that bundling is a win on balance if the editor has good signature help support. This might be personal enough to make an option.

I built a hacky prototype if you want to play with this behavior: patch in

The behavior is to bundle together c++ method calls by name, and function calls by qualified name (namespaces must match). I don’t know much about ObjC, I’m not sure if grouping on the first chunk of the selector would make sense.

Cool things you could do:

  • pull individual elements out of the bundle if they’re high ranking enough
  • explode the bundle once the query is unambiguous (client-side filtering is a problem here)
  • attempt to summarize similar signatures (e.g. show return type if it’s the same for all overloads, show similar parts of const/non-const member overloads)

Hi Sam,

I also agree that merging the results provides better experience overall, if signature help is there. I think it’s a clear win in almost all of the cases, especially for functions that have lots of overloads.

Bundling cons:

  • complicated interactions with e.g. include insertion

One (the only) way out of this particular problem is merging only when inserted includes are the same.

wrt to the signatures, if we start merging the results, maybe we could even provide a user option to not show the signatures at all. They are often noisy if the function contains more than few parameters.
I would personally be fine with exploring the function type with signatureHelp and keeping completion list narrower. WDYT?


I think the folding makes sense. My only concern was that the user could mistakenly think there are no overloads before choosing a completion item but I see in the screenshot that it is communicated with the [overloaded]. Maybe as a bonus it could say how many overloads? i.e. [6 overloads] :slight_smile:


Yeah, merging only results from the same header makes sense to me. It’s not in the prototype because

I’d personally find it hard to give up the signature for non-overloads (and non-functions). But this does strike me as a place a (second) option might make sense.

I assumed people would want the popular/likely overload bundles exploded into individual items, but it seems that’s just me. Maybe explode-after-full-name is a good fallback for editors that don’t support signature help?

[6 overloads] is better than [overloaded] for sure. I was just too tired to fix it on Friday :slight_smile:

Sorry for being late to the discussion.

I agree that for Objective-C it doesn’t make sense to omit parameter names to group methods with the same name.