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

时光毁灭记忆、已成空白 提交于 2019-12-10 16:58:09

问题


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 modify the range according to it.

The extension is at: https://marketplace.visualstudio.com/items?itemName=serayuzgur.crates

You can see the hoverMessage from the GIF


回答1:


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



来源:https://stackoverflow.com/questions/50221763/visual-studio-code-is-it-possible-to-make-a-decorations-hovermessage-clickable

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!