Visual Studio Code: Is it possible to make a decorations hoverMessage clickable

前端 未结 1 1034
醉梦人生
醉梦人生 2021-01-18 18:31

Hi I am developing an extension for VSCode. I am decorating the text editor and hovering some items. Is it possible to make clickable items at hoverMessage and

相关标签:
1条回答
  • 2021-01-18 19:25

    Yes, using markdown you can then create a command link that will execute a command when a user clicks on it:

    import * as vscode from 'vscode';
    
    const myContent = new vscode.MarkdownString('[link](command:myCommand?arg1)');
    
    // Command Uris are disabled by default for security reasons.
    // If you set this flag, make sure your content is not constructed
    // using untrusted/unsanitized text.
    myContent.isTrusted = true;
    
    const myHover = new Hover(myContent);
    

    This command can perform whatever action you want

    0 讨论(0)
提交回复
热议问题