Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updating the TerminalInstance to only register link providers once. #135419

Merged
merged 1 commit into from
Oct 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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;
}
Expand Down
5 changes: 5 additions & 0 deletions src/vs/workbench/contrib/terminal/browser/terminalInstance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down