c++visual-studio-codecode-completion

How can I make VS Code always show all inline details in the suggestion widget?


In VS Code, you can use CTRL + Space to trigger suggestion (at least that's what I use for Trigger Suggest command). The command will show the suggestion; e.g., using it on an object will show it's method and properties.

It will also show the type hint only for the currently selected suggestion. How can I make it to show all type hint for all suggestion?

enter image description here


Solution

  • I think you're at the mercy of however the extension of interest is implementing suggestions using the VS Code API.

    It's a bit complicated and there's some history involved. The relevant extension API points include CompletionItemProvider<T>, CompletionItem, and CompletionItemLabel. CompletionItem has detail?: string, documentation?: string | MarkdownString, and label: string | CompletionItemLabel.

    Providers can delay the computation of the detail and documentation properties by implementing the resolveCompletionItem-function.

    When the CompletionItemLabel form of label is used and its description and/or detail properties are populated, those are always rendered for the suggestion in the inline details portion of the suggestion widget- regardless of whether the suggestion is the currently selected one. Otherwise, the CompletionItem's detail property is rendered in the inline details portion of the suggestion widget for the currently selected suggestion only (probably due to the complication of resolveCompletionItem), and only when the suggestion details panel is toggled off/closed (when it is toggled on/open, the CompletionItem's detail and documentation are rendered in the suggestion details panel if they exist).

    If you're interested in figuring out exactly what your extension of interest is doing, you can always go read its source code (if it's open-source), or you can dissect your VS Code as it's running to figure it out.

    Note that you can toggle whether inline details are rendered at all for the suggest widget using the editor.suggest.showInlineDetails setting, which defaults to true.

    If you're interested in the history of how this CompletionItemLabel thing came about, see Consider showing completion item detail if available for all list items #39441, which I found by googling "github vscode issues suggestion inline details for all labels always".