mirror of
https://github.com/Microsoft/vscode
synced 2024-08-25 03:56:03 +00:00
Merge pull request #209376 from microsoft/tyriar/176812
Support any OSC link scheme
This commit is contained in:
commit
44fbf7f36a
|
@ -95,6 +95,7 @@ export const enum TerminalSettingId {
|
|||
WindowsEnableConpty = 'terminal.integrated.windowsEnableConpty',
|
||||
WordSeparators = 'terminal.integrated.wordSeparators',
|
||||
EnableFileLinks = 'terminal.integrated.enableFileLinks',
|
||||
AllowedLinkSchemes = 'terminal.integrated.allowedLinkSchemes',
|
||||
UnicodeVersion = 'terminal.integrated.unicodeVersion',
|
||||
LocalEchoLatencyThreshold = 'terminal.integrated.localEchoLatencyThreshold',
|
||||
LocalEchoEnabled = 'terminal.integrated.localEchoEnabled',
|
||||
|
|
|
@ -176,6 +176,7 @@ export interface ITerminalConfiguration {
|
|||
windowsEnableConpty: boolean;
|
||||
wordSeparators: string;
|
||||
enableFileLinks: 'off' | 'on' | 'notRemote';
|
||||
allowedLinkSchemes: string[];
|
||||
unicodeVersion: '6' | '11';
|
||||
localEchoLatencyThreshold: number;
|
||||
localEchoExcludePrograms: ReadonlyArray<string>;
|
||||
|
|
|
@ -489,6 +489,21 @@ const terminalConfiguration: IConfigurationNode = {
|
|||
],
|
||||
default: 'on'
|
||||
},
|
||||
[TerminalSettingId.AllowedLinkSchemes]: {
|
||||
description: localize('terminal.integrated.allowedLinkSchemes', "An array of strings containing the URI schemes that the terminal is allowed to open links for. By default, only a small subset of possible schemes are allowed for security reasons."),
|
||||
type: 'array',
|
||||
items: {
|
||||
type: 'string'
|
||||
},
|
||||
default: [
|
||||
'file',
|
||||
'http',
|
||||
'https',
|
||||
'mailto',
|
||||
'vscode',
|
||||
'vscode-insiders',
|
||||
]
|
||||
},
|
||||
[TerminalSettingId.UnicodeVersion]: {
|
||||
type: 'string',
|
||||
enum: ['6', '11'],
|
||||
|
|
|
@ -20,7 +20,7 @@ import { TerminalLocalFileLinkOpener, TerminalLocalFolderInWorkspaceLinkOpener,
|
|||
import { TerminalLocalLinkDetector } from 'vs/workbench/contrib/terminalContrib/links/browser/terminalLocalLinkDetector';
|
||||
import { TerminalUriLinkDetector } from 'vs/workbench/contrib/terminalContrib/links/browser/terminalUriLinkDetector';
|
||||
import { TerminalWordLinkDetector } from 'vs/workbench/contrib/terminalContrib/links/browser/terminalWordLinkDetector';
|
||||
import { ITerminalExternalLinkProvider, TerminalLinkQuickPickEvent } from 'vs/workbench/contrib/terminal/browser/terminal';
|
||||
import { ITerminalConfigurationService, ITerminalExternalLinkProvider, TerminalLinkQuickPickEvent } from 'vs/workbench/contrib/terminal/browser/terminal';
|
||||
import { ILinkHoverTargetOptions, TerminalHover } from 'vs/workbench/contrib/terminal/browser/widgets/terminalHoverWidget';
|
||||
import { TerminalWidgetManager } from 'vs/workbench/contrib/terminal/browser/widgets/widgetManager';
|
||||
import { IXtermCore } from 'vs/workbench/contrib/terminal/browser/xterm-private';
|
||||
|
@ -32,6 +32,7 @@ import { convertBufferRangeToViewport } from 'vs/workbench/contrib/terminalContr
|
|||
import { RunOnceScheduler } from 'vs/base/common/async';
|
||||
import { ITerminalLogService } from 'vs/platform/terminal/common/terminal';
|
||||
import { TerminalMultiLineLinkDetector } from 'vs/workbench/contrib/terminalContrib/links/browser/terminalMultiLineLinkDetector';
|
||||
import { INotificationService, Severity } from 'vs/platform/notification/common/notification';
|
||||
|
||||
export type XtermLinkMatcherHandler = (event: MouseEvent | undefined, link: string) => Promise<void>;
|
||||
|
||||
|
@ -53,7 +54,9 @@ export class TerminalLinkManager extends DisposableStore {
|
|||
capabilities: ITerminalCapabilityStore,
|
||||
private readonly _linkResolver: ITerminalLinkResolver,
|
||||
@IConfigurationService private readonly _configurationService: IConfigurationService,
|
||||
@ITerminalConfigurationService private readonly _terminalConfigurationService: ITerminalConfigurationService,
|
||||
@IInstantiationService private readonly _instantiationService: IInstantiationService,
|
||||
@INotificationService private readonly _notificationService: INotificationService,
|
||||
@ITerminalLogService private readonly _logService: ITerminalLogService,
|
||||
@ITunnelService private readonly _tunnelService: ITunnelService
|
||||
) {
|
||||
|
@ -99,7 +102,30 @@ export class TerminalLinkManager extends DisposableStore {
|
|||
activeTooltipScheduler?.dispose();
|
||||
}));
|
||||
this._xterm.options.linkHandler = {
|
||||
activate: (_, text) => {
|
||||
allowNonHttpProtocols: true,
|
||||
activate: (event, text) => {
|
||||
if (!this._isLinkActivationModifierDown(event)) {
|
||||
return;
|
||||
}
|
||||
const colonIndex = text.indexOf(':');
|
||||
if (colonIndex === -1) {
|
||||
throw new Error(`Could not find scheme in link "${text}"`);
|
||||
}
|
||||
const scheme = text.substring(0, colonIndex);
|
||||
if (this._terminalConfigurationService.config.allowedLinkSchemes.indexOf(scheme) === -1) {
|
||||
this._notificationService.prompt(Severity.Warning, nls.localize('scheme', 'Opening URIs can be insecure, do you want to allow opening links with the scheme {0}?', scheme), [
|
||||
{
|
||||
label: nls.localize('allow', 'Allow {0}', scheme),
|
||||
run: () => {
|
||||
const allowedLinkSchemes = [
|
||||
...this._terminalConfigurationService.config.allowedLinkSchemes,
|
||||
scheme
|
||||
];
|
||||
this._configurationService.updateValue(`terminal.integrated.allowedLinkSchemes`, allowedLinkSchemes);
|
||||
}
|
||||
}
|
||||
]);
|
||||
}
|
||||
this._openers.get(TerminalBuiltinLinkType.Url)?.open({
|
||||
type: TerminalBuiltinLinkType.Url,
|
||||
text,
|
||||
|
|
Loading…
Reference in a new issue