Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

248
Visualizações
How to run command after the completion is inserted into the text editor (VS Code Extension)?

In my VS Code Extension I would like the opening and closing parentheses to be inserted automatically after a function is selected from the list provided by the completion item provider.

After the parentheses are added, I would like the extension to trigger the signature help provider (note that VS Code triggers the signature help provider when you manually type the opening parenthesis (.

Here's a snippet of what I've added inside the provideCompletionItems method:

myFunctions.forEach((func) => {
    const completion = new CompletionItem(func, CompletionItemKind.Function);
    completion.detail = func.signature;
    completion.documentation = func.description;
    completion.insertText = func + '(';
    ...
});

I am aware that I can execute a command after inserting a completion by adding something like

completion.command = ...

The VS Code Extension API has vscode.executeSignatureHelpProvider as a built-in command to execute the Signature Help Provider. Thus, I would run this command like this:

vscode.commands.executeCommand('vscode.executeSignatureHelpProvider', document.uri, position)

However, I don't know how to run this command as part of the command variable, meaning that I can't do

completion.command = vscode.commands.executeCommand('vscode.executeSignatureHelpProvider', document.uri, position)

because the command variable accepts only the type Command.

So, how would I be able to run a command after the completion is inserted into the editor?


SOLUTION:

Based on the answers below, I realized I was using the wrong command to trigger the parameter hints widget. Instead, I used the editor.action.triggerParameterHints command:

completion.command = { command: 'editor.action.triggerParameterHints', title: '' };
about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

Try the editor.action.triggerParameterHints command instead. If you have registered your own SignatureHelpProvider that should trigger it to run. If you haven't registered your own, that should trigger the default provider.

completion.command = "editor.action.triggerParameterHints";


You can also invoke a command, if you have more work to do there, via this in your CompletionItem:

newCommand.command = "<your extension name>.selectDigitInCompletion";
newCommand.title = "Select the digit 'n' in completionItem";
newCommand.arguments = [key, replaceRange, position];  // whatever args you want to pass to the command
completion.command = newCommand;

And then that command is registered somewhere - it doesn't have to be in the package.json:

vscode.commands.registerCommand('<your extension name>.selectDigitInCompletion', async (completionText, completionRange, position) => {

// ...

// access your passed-in args `completionText`,`completionRange` and `position` here
// await vscode.commands.executeCommand('vscode.executeSignatureHelpProvider', document.uri, position)

...

}
about 4 years ago · Juan Pablo Isaza Relatório

0

assign an instance of the Command object

completion.command = { command: 'vscode.executeSignatureHelpProvider', title: 'Signature' };
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda