Skip to content

Commit

Permalink
Support enableFileLinks
Browse files Browse the repository at this point in the history
Fixes #95082
  • Loading branch information
Tyriar committed Apr 19, 2020
1 parent 86ccb2f commit 1257f3b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { DisposableStore, IDisposable, dispose } from 'vs/base/common/lifecycle'
import { IOpenerService } from 'vs/platform/opener/common/opener';
import { TerminalWidgetManager } from 'vs/workbench/contrib/terminal/browser/widgets/widgetManager';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { ITerminalProcessManager, ITerminalConfigHelper } from 'vs/workbench/contrib/terminal/common/terminal';
import { ITerminalProcessManager, ITerminalConfigHelper, ITerminalConfiguration, TERMINAL_CONFIG_SECTION } from 'vs/workbench/contrib/terminal/common/terminal';
import { ITextEditorSelection } from 'vs/platform/editor/common/editor';
import { IEditorService } from 'vs/workbench/services/editor/common/editorService';
import { IFileService } from 'vs/platform/files/common/files';
Expand Down Expand Up @@ -301,21 +301,21 @@ export class TerminalLinkManager extends DisposableStore {
public registerLinkProvider(): void {
// Web links
const wrappedActivateCallback = this._wrapLinkHandler((_, link) => this._handleProtocolLink(link));
this._linkProviders.push(this._xterm.registerLinkProvider(
this._instantiationService.createInstance(TerminalProtocolLinkProvider, this._xterm, wrappedActivateCallback, this._tooltipCallback2.bind(this))
));

// Validated local links
const wrappedTextLinkActivateCallback = this._wrapLinkHandler((_, link) => this._handleLocalLink(link));
this._linkProviders.push(this._xterm.registerLinkProvider(
this._instantiationService.createInstance(TerminalValidatedLocalLinkProvider,
const protocolProvider = this._instantiationService.createInstance(TerminalProtocolLinkProvider, this._xterm, wrappedActivateCallback, this._tooltipCallback2.bind(this));
this._linkProviders.push(this._xterm.registerLinkProvider(protocolProvider));

// Validated local linksSECTION).enableFileLinks);
if (this._configurationService.getValue<ITerminalConfiguration>(TERMINAL_CONFIG_SECTION).enableFileLinks) {
const wrappedTextLinkActivateCallback = this._wrapLinkHandler((_, link) => this._handleLocalLink(link));
const validatedProvider = this._instantiationService.createInstance(TerminalValidatedLocalLinkProvider,
this._xterm,
this._processManager.os || OS,
wrappedTextLinkActivateCallback,
this._wrapLinkHandler.bind(this),
this._tooltipCallback2.bind(this),
async (link, cb) => cb(await this._resolvePath(link)))
));
async (link, cb) => cb(await this._resolvePath(link)));
this._linkProviders.push(this._xterm.registerLinkProvider(validatedProvider));
}

// Word links
const wordHandler = async (link: string) => {
Expand All @@ -337,9 +337,8 @@ export class TerminalLinkManager extends DisposableStore {
this._quickInputService.quickAccess.show(link);
};
const wrappedWordActivateCallback = this._wrapLinkHandler((_, link) => wordHandler(link));
this._linkProviders.push(this._xterm.registerLinkProvider(
this._instantiationService.createInstance(TerminalWordLinkProvider, this._xterm, wrappedWordActivateCallback, this._tooltipCallback2.bind(this))
));
const wordProvider = this._instantiationService.createInstance(TerminalWordLinkProvider, this._xterm, wrappedWordActivateCallback, this._tooltipCallback2.bind(this));
this._linkProviders.push(this._xterm.registerLinkProvider(wordProvider));
}

protected _wrapLinkHandler(handler: (event: MouseEvent | undefined, link: string) => void): XtermLinkMatcherHandler {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ export const terminalConfiguration: IConfigurationNode = {
default: false
},
'terminal.integrated.enableFileLinks': {
description: localize('terminal.integrated.enableFileLinks', "Whether to enable file links in the terminal. Links can be slow when working on a network drive in particular because each file link is verified against the file system."),
description: localize('terminal.integrated.enableFileLinks', "Whether to enable file links in the terminal. Links can be slow when working on a network drive in particular because each file link is verified against the file system. Changing this will take effect only in new terminals."),
type: 'boolean',
default: true
},
Expand Down

0 comments on commit 1257f3b

Please sign in to comment.