问题
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