chaya D
chaya D

Reputation: 151

vscode.showInformationMessage - how to add a header to message

I am publishing a vscode extension and have a simple header and message to show up. the message and the items are show as expected, but i couldn't find the way to add a header with text. how can I do this? should I use a different message method? the current code:

    const header = { title: 'Confirmation Needed' };               
    return vscode.window.showInformationMessage(text, ...["Ok", "Cancel"]);

Upvotes: 4

Views: 3941

Answers (1)

Empiire
Empiire

Reputation: 565

You can achieve this by using the modal option:

const header = "Message Header";
const options: vscode.MessageOptions = { detail: 'Message Description', modal: true };
vscode.window.showInformationMessage(header, options, ...["Ok"]).then((item)=>{
    console.log(item);
});

Which will look like this: modal with "OK" and "cancel" button

Note, that item will contain the string of the pressed button, but will be undefined if the user clicks on "Cancel".


Unfortunately, it is not be possible to do this without the modal dialog, according to the docs

Upvotes: 7

Related Questions