Skip to content

Commit

Permalink
Trigger signature help when accepting code completions, where appropr…
Browse files Browse the repository at this point in the history
…iate. (#398)

As recommended in microsoft/vscode#78806
This is an incomplete fix but better than nothing.
Also files microsoft/vscode#164310 in case
VSCode can improve the behavior here.

fixes #390
  • Loading branch information
sam-mccall authored Mar 3, 2024
1 parent eca1e05 commit f7b1f26
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/clangd-context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,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 &&
!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

0 comments on commit f7b1f26

Please sign in to comment.