Skip to content

Terminal link hover stopped being a link #273097

@Tyriar

Description

@Tyriar

This used to be a link you could click, allowing activating the link with mouse-only access:

Image

Label source:

private _getLinkHoverString(uri: string, label: string | undefined): IMarkdownString {
const editorConf = this._configurationService.getValue<{ multiCursorModifier: 'ctrlCmd' | 'alt' }>('editor');
let clickLabel = '';
if (editorConf.multiCursorModifier === 'ctrlCmd') {
if (isMacintosh) {
clickLabel = nls.localize('terminalLinkHandler.followLinkAlt.mac', "option + click");
} else {
clickLabel = nls.localize('terminalLinkHandler.followLinkAlt', "alt + click");
}
} else {
if (isMacintosh) {
clickLabel = nls.localize('terminalLinkHandler.followLinkCmd', "cmd + click");
} else {
clickLabel = nls.localize('terminalLinkHandler.followLinkCtrl', "ctrl + click");
}
}
let fallbackLabel = nls.localize('followLink', "Follow link");
try {
if (this._tunnelService.canTunnel(URI.parse(uri))) {
fallbackLabel = nls.localize('followForwardedLink', "Follow link using forwarded port");
}
} catch {
// No-op, already set to fallback
}
const markdown = new MarkdownString('', true);
// Escapes markdown in label & uri
if (label) {
label = markdown.appendText(label).value;
markdown.value = '';
}
if (uri) {
uri = markdown.appendText(uri).value;
markdown.value = '';
}
label = label || fallbackLabel;
// Use the label when uri is '' so the link displays correctly
uri = uri || label;
// Although if there is a space in the uri, just replace it completely
if (/(\s|&nbsp;)/.test(uri)) {
uri = nls.localize('followLinkUrl', 'Link');
}
return markdown.appendLink(uri, label).appendMarkdown(` (${clickLabel})`);
}

Hover creation:

attach(container: HTMLElement): void {
const showLinkHover = this._configurationService.getValue(TerminalSettingId.ShowLinkHover);
if (!showLinkHover) {
return;
}
const target = new CellHoverTarget(container, this._targetOptions);
const hover = this._hoverService.showInstantHover({
target,
content: this._text,
actions: this._actions,
linkHandler: this._linkHandler,
// .xterm-hover lets xterm know that the hover is part of a link
additionalClasses: ['xterm-hover']
});
if (hover) {
this._register(hover);
}
}

Metadata

Metadata

Assignees

Labels

bugIssue identified by VS Code Team member as probable bugterminal-links

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions