diff --git a/src/vs/workbench/contrib/terminal/browser/links/terminalLinkManager.ts b/src/vs/workbench/contrib/terminal/browser/links/terminalLinkManager.ts index bda886dc76eb2..fda5316ce1352 100644 --- a/src/vs/workbench/contrib/terminal/browser/links/terminalLinkManager.ts +++ b/src/vs/workbench/contrib/terminal/browser/links/terminalLinkManager.ts @@ -45,7 +45,7 @@ export class TerminalLinkManager extends DisposableStore { private _widgetManager: TerminalWidgetManager | undefined; private _processCwd: string | undefined; private _standardLinkProviders: ILinkProvider[] = []; - private _standardLinkProvidersDisposables: IDisposable[] = []; + private _linkProvidersDisposables: IDisposable[] = []; constructor( private _xterm: Terminal, @@ -137,18 +137,23 @@ export class TerminalLinkManager extends DisposableStore { this._processCwd = processCwd; } + private _clearLinkProviders(): void { + dispose(this._linkProvidersDisposables); + this._linkProvidersDisposables = []; + } + private _registerStandardLinkProviders(): void { - dispose(this._standardLinkProvidersDisposables); - this._standardLinkProvidersDisposables = []; for (const p of this._standardLinkProviders) { - this._standardLinkProvidersDisposables.push(this._xterm.registerLinkProvider(p)); + this._linkProvidersDisposables.push(this._xterm.registerLinkProvider(p)); } } registerExternalLinkProvider(instance: ITerminalInstance, linkProvider: ITerminalExternalLinkProvider): IDisposable { + // Clear and re-register the standard link providers so they are a lower priority that the new one + this._clearLinkProviders(); const wrappedLinkProvider = this._instantiationService.createInstance(TerminalExternalLinkProviderAdapter, this._xterm, instance, linkProvider, this._wrapLinkHandler.bind(this), this._tooltipCallback.bind(this)); const newLinkProvider = this._xterm.registerLinkProvider(wrappedLinkProvider); - // Re-register the standard link providers so they are a lower priority that the new one + this._linkProvidersDisposables.push(newLinkProvider); this._registerStandardLinkProviders(); return newLinkProvider; } diff --git a/src/vs/workbench/contrib/terminal/browser/terminalInstance.ts b/src/vs/workbench/contrib/terminal/browser/terminalInstance.ts index e76a1dd02077e..43b3d72cddeec 100644 --- a/src/vs/workbench/contrib/terminal/browser/terminalInstance.ts +++ b/src/vs/workbench/contrib/terminal/browser/terminalInstance.ts @@ -687,6 +687,11 @@ export class TerminalInstance extends Disposable implements ITerminalInstance { // Init winpty compat and link handler after process creation as they rely on the // underlying process OS this._processManager.onProcessReady((processTraits) => { + // If links are ready, do not re-create the manager. + if (this._areLinksReady) { + return; + } + if (this._processManager.os === OperatingSystem.Windows) { xterm.setOption('windowsMode', processTraits.requiresWindowsMode || false); // Force line data to be sent when the cursor is moved, the main purpose for