Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

like image 672
Seray Uzgur Avatar asked May 07 '18 20:05

Seray Uzgur


People also ask

How I can make Ctrl Click to go to definition in Visual Studio Code?

Tip: You can jump to the definition with Ctrl+Click or open the definition to the side with Ctrl+Alt+Click.

How do I activate VS Code icons?

Once installed and after reloading vscode , you will be presented with a message to Activate the icons. In case this doesn't happen, navigate to: Linux & Windows => File > Preferences > File Icon Theme > VSCode Icons. MacOS => Code > Preferences > File Icon Theme > VSCode Icons.


1 Answers

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

like image 134
Matt Bierner Avatar answered Oct 02 '22 10:10

Matt Bierner