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.

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 clangd#390
  • Loading branch information
sam-mccall committed Oct 22, 2022
1 parent 687314d commit b264860
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 @@ -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 &&
!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 b264860

Please sign in to comment.