Add a setting for disabling port forwarding on click (#168311)

Fixes https://github.com/microsoft/vscode-remote-release/issues/6972

Co-authored-by: Daniel Imms <2193314+Tyriar@users.noreply.github.com>
This commit is contained in:
Alex Ross
2022-12-19 14:26:23 +01:00
committed by GitHub
co-authored by Daniel Imms
parent 23fb7c27fa
commit f2edffb3d5
3 changed files with 13 additions and 4 deletions
@@ -17,6 +17,7 @@ import { StandardKeyboardEvent } from 'vs/base/browser/keyboardEvent';
import { KeyCode } from 'vs/base/common/keyCodes';
import { localize } from 'vs/nls';
import { ITunnelService } from 'vs/platform/tunnel/common/tunnel';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
const CONTROL_CODES = '\\u0000-\\u0020\\u007f-\\u009f';
const WEB_LINK_REGEX = new RegExp('(?:[a-zA-Z][a-zA-Z0-9+.-]{2,}:\\/\\/|data:|www\\.)[^\\s' + CONTROL_CODES + '"]{2,}[^\\s' + CONTROL_CODES + '"\')}\\],:;.!?]', 'ug');
@@ -45,7 +46,8 @@ export class LinkDetector {
@IOpenerService private readonly openerService: IOpenerService,
@IPathService private readonly pathService: IPathService,
@ITunnelService private readonly tunnelService: ITunnelService,
@IWorkbenchEnvironmentService private readonly environmentService: IWorkbenchEnvironmentService
@IWorkbenchEnvironmentService private readonly environmentService: IWorkbenchEnvironmentService,
@IConfigurationService private readonly configurationService: IConfigurationService
) {
// noop
}
@@ -140,7 +142,7 @@ export class LinkDetector {
return;
}
this.openerService.open(url, { allowTunneling: !!this.environmentService.remoteAuthority });
this.openerService.open(url, { allowTunneling: (!!this.environmentService.remoteAuthority && this.configurationService.getValue('remote.forwardOnOpen')) });
});
return link;
@@ -363,6 +363,11 @@ Registry.as<IConfigurationRegistry>(ConfigurationExtensions.Configuration)
],
default: 'process'
},
'remote.forwardOnOpen': {
type: 'boolean',
description: localize('remote.forwardOnClick', "Controls whether local URLs with a port will be forwarded when opened from the terminal and the debug console."),
default: true
},
// Consider making changes to extensions\configuration-editing\schemas\devContainer.schema.src.json
// and extensions\configuration-editing\schemas\attachContainer.schema.json
// to keep in sync with devcontainer.json schema.
@@ -21,6 +21,7 @@ import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/
import { IHostService } from 'vs/workbench/services/host/browser/host';
import { QueryBuilder } from 'vs/workbench/services/search/common/queryBuilder';
import { ISearchService } from 'vs/workbench/services/search/common/search';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { getLinkSuffix } from 'vs/workbench/contrib/terminal/browser/links/terminalLinkParsing';
export class TerminalLocalFileLinkOpener implements ITerminalLinkOpener {
@@ -238,7 +239,8 @@ interface IResourceMatch {
export class TerminalUrlLinkOpener implements ITerminalLinkOpener {
constructor(
private readonly _isRemote: boolean,
@IOpenerService private readonly _openerService: IOpenerService
@IOpenerService private readonly _openerService: IOpenerService,
@IConfigurationService private readonly _configurationService: IConfigurationService
) {
}
@@ -249,7 +251,7 @@ export class TerminalUrlLinkOpener implements ITerminalLinkOpener {
// It's important to use the raw string value here to avoid converting pre-encoded values
// from the URL like `%2B` -> `+`.
this._openerService.open(link.text, {
allowTunneling: this._isRemote,
allowTunneling: this._isRemote && this._configurationService.getValue('remote.forwardOnOpen'),
allowContributedOpeners: true,
openExternal: true
});