API介绍
该类用于构造补全项。 官方文档: https://code.visualstudio.com/api/references/vscode-api#CompletionItem
问题
如何在补全列表中持续显示所有补全项的描述? 效果:
new vscode.CompletionItem({
label: key,
description: item.description
})
如何使用Snippet格式进行补全? 效果:
const proposal = new vscode.CompletionItem({
label: key,
description: item.description
});
let snippetStr = '';
item.body.forEach((str, idx) => {
snippetStr += str
if (idx >= item.body.length - 1) return
snippetStr += '\n'
})
proposal.insertText = new vscode.SnippetString(snippetStr);
如何模糊查询出补全项? 效果:
const commandCompletion = new vscode.CompletionItem(label);
commandCompletion.filterText = label.split('').join('-');
如何在选中补全项后继续调用补全事件? 效果:
const commandCompletion = new vscode.CompletionItem(label);
commandCompletion.command = {
command: 'editor.action.triggerSuggest'
});
|