根据 API 文档,消息框可以接受第二个参数:一个字符串数组,充当消息框上的操作(通常只有一个关闭按钮/操作):
https://code.visualstudio.com/docs/extensionAPI/vscode-api#_window
showInformationMessage(message: string, ...items: string[]): Thenable<string>
所以我尝试了这个:
vscode.window.showInformationMessage('hello world', ['test','taco','cheeseburger'], function(value){
console.log(value + " was clicked");
});
但这似乎不起作用。我像往常一样收到消息框和关闭按钮。但随后关闭按钮的左侧似乎是另一个没有文本或标题的单个按钮。
另一个函数定义是:
showInformationMessage<T extends MessageItem>(message: string, ...items: T[]): Thenable<T>
所以我尝试了这样的事情:
let message: vscode.MessageItem = { title: 'testing' };
vscode.window.showInformationMessage('hello', [message], function(value){
console.log(value + " was clicked");
});
但这似乎也不起作用。这方面的文档很少,所以我无法弄清楚。