挂钩 IntelliSense 完成列表

Hook IntelliSense completion list

是否可以hook完成列表显示功能?

我主要想创建一个扩展,当显示完成列表时,获取第一个建议并将其存储在文件中。

我发现可以使用 complex commands API 获取建议列表。

命令名称是:vscode.executeCompletionItemProvider 我们可以使用vscode.commands.executeCommand

调用它
// the Position object gives you the line and character where the cursor is
const position = editor.selection.active;

// Get document Uri
const docUri = vscode.window.activeTextEditor.document.uri;

completionList = vscode.commands.executeCommand(
   'vscode.executeCompletionItemProvider',
    docUri,
    position
)