Skip to content

Trigger signature help when accepting code completions, where appropriate #398

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 3, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions src/clangd-context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,20 @@ export class ClangdContext implements vscode.Disposable {
// notice until the behavior was in several releases, so we need
// to override it on the client.
item.commitCharacters = [];
// VSCode won't automatically trigger signature help when entering
// a placeholder, e.g. if the completion inserted brackets and
// placed the cursor inside them.
// https://github.com/microsoft/vscode/issues/164310
// They say a plugin should trigger this, but LSP has no mechanism.
// https://github.com/microsoft/language-server-protocol/issues/274
// (This workaround is incomplete, and only helps the first param).
if (item.insertText instanceof vscode.SnippetString &&
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it intentional that the workaround is not reached if the user has set "clangd.serverCompletionRanking": false (which causes us to early-return near the top of this function)?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(The likely answer here is that there's no reason the workaround couldn't also apply to the "clangd.serverCompletionRanking": false case, we'd just have to reorganize the code a bit to handle that case as well. We can do that in a follow-up patch if anyone asks for it.)

!item.command &&
item.insertText.value.match(/[([{<,] ?\$\{?[01]\D/))
item.command = {
title: 'Signature help',
command: 'editor.action.triggerParameterHints'
};
return item;
})
return new vscode.CompletionList(items, /*isIncomplete=*/ true);
Expand Down