Skip to content

Allow DocumentLinks to provide hover message #72824

@mjbvz

Description

@mjbvz

Problem

The markdown document link provider creates document links that use command URIs. Currently these have a generic hover message in the editor:

Screen Shot 2019-04-24 at 11 07 16 AM

It'd be nicer if a message describing what the link does where shown, something like: Open file. cmd+click to execute

Api

Two ideas on this

Allow DocumentLink to take a Command instead of URI

	export class DocumentLink {

		/**
		 * The range this link applies to.
		 */
		range: Range;

		/**
		 * The uri this link points to or a command executed when the document link is clicked.
		 */
		target?: Uri | Command;

		/**
		 * Creates a new document link.
		 *
		 * @param range The range the document link applies to. Must not be empty.
		 * @param target The uri the document link points to or a command executed when the document link is clicked.
		 */
		constructor(range: Range, target?: Uri | Command);
	}

This would let extensions to set a title or tooltip in the document link.

new vscode.DocumentLink(new vscode.Range(0, 0, 0, 0), {
    title: 'Does thing when clicked',
    command: 'ext.doThing'
})

Add a title property on DocumentLink

	export class DocumentLink {
		/**
		 * Label for the document link shown in the UI on hover
		 */
               tooltip?: string;

		/**
		 * The range this link applies to.
		 */
		range: Range;

		/**
		 * The uri this link points to.
		 */
		target?: Uri;

		/**
		 * Creates a new document link.
		 *
		 * @param range The range the document link applies to. Must not be empty.
		 * @param target The uri the document link points to.
		 */
		constructor(range: Range, target?: Uri);
	}

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions