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

fix terminal disposable leaks, get dropdown menu to show for terminal editors #239742

Merged
merged 14 commits into from
Feb 6, 2025
Merged
4 changes: 2 additions & 2 deletions src/vs/workbench/contrib/terminal/browser/terminalService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -846,7 +846,7 @@ export class TerminalService extends Disposable implements ITerminalService {
instance.onDidFocus(this._onDidChangeActiveInstance.fire, this._onDidChangeActiveInstance),
instance.onRequestAddInstanceToGroup(async e => await this._addInstanceToGroup(instance, e))
];
instance.onDisposed(() => dispose(instanceDisposables));
this._register(instance.onDisposed(() => dispose(instanceDisposables)));
meganrogge marked this conversation as resolved.
Show resolved Hide resolved
}

private async _addInstanceToGroup(instance: ITerminalInstance, e: IRequestAddInstanceToGroupEvent): Promise<void> {
Expand Down Expand Up @@ -1002,7 +1002,7 @@ export class TerminalService extends Disposable implements ITerminalService {
const instance = this._terminalInstanceService.createInstance(shellLaunchConfig, TerminalLocation.Panel);
this._backgroundedTerminalInstances.push(instance);
this._backgroundedTerminalDisposables.set(instance.instanceId, [
instance.onDisposed(this._onDidDisposeInstance.fire, this._onDidDisposeInstance)
this._register(instance.onDisposed(this._onDidDisposeInstance.fire, this._onDidDisposeInstance))
meganrogge marked this conversation as resolved.
Show resolved Hide resolved
]);
this._terminalHasBeenCreated.set(true);
return instance;
Expand Down
4 changes: 2 additions & 2 deletions src/vs/workbench/contrib/terminal/browser/terminalView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,11 +127,11 @@ export class TerminalViewPane extends ViewPane {
}
}));
this._register(this._terminalService.onDidCreateInstance((i) => {
i.capabilities.onDidAddCapabilityType(c => {
this._register(i.capabilities.onDidAddCapabilityType(c => {
if (c === TerminalCapability.CommandDetection && this._gutterDecorationsEnabled()) {
this._parentDomElement?.classList.add('shell-integration');
}
});
}));
meganrogge marked this conversation as resolved.
Show resolved Hide resolved
}));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -308,11 +308,11 @@ export class XtermTerminal extends Disposable implements IXtermTerminal, IDetach
updateProgress();
const commandDetection = this._capabilities.get(TerminalCapability.CommandDetection);
if (commandDetection) {
commandDetection.onCommandFinished(() => progressAddon.progress = { state: 0, value: 0 });
this._register(commandDetection.onCommandFinished(() => progressAddon.progress = { state: 0, value: 0 }));
} else {
const disposable = this._capabilities.onDidAddCapability(e => {
if (e.id === TerminalCapability.CommandDetection) {
(e.capability as CommandDetectionCapability).onCommandFinished(() => progressAddon.progress = { state: 0, value: 0 });
this._register((e.capability as CommandDetectionCapability).onCommandFinished(() => progressAddon.progress = { state: 0, value: 0 }));
this._store.delete(disposable);
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,17 +45,25 @@ class TerminalHistoryContribution extends Disposable implements ITerminalContrib
this._register(_ctx.instance.capabilities.onDidAddCapabilityType(e => {
switch (e) {
case TerminalCapability.CwdDetection: {
_ctx.instance.capabilities.get(TerminalCapability.CwdDetection)?.onDidChangeCwd(e => {
const cwdDetection = _ctx.instance.capabilities.get(TerminalCapability.CwdDetection);
if (!cwdDetection) {
return;
}
this._register(cwdDetection.onDidChangeCwd(e => {
this._instantiationService.invokeFunction(getDirectoryHistory)?.add(e, { remoteAuthority: _ctx.instance.remoteAuthority });
});
}));
break;
}
case TerminalCapability.CommandDetection: {
_ctx.instance.capabilities.get(TerminalCapability.CommandDetection)?.onCommandFinished(e => {
const commandDetection = _ctx.instance.capabilities.get(TerminalCapability.CommandDetection);
if (!commandDetection) {
return;
}
this._register(commandDetection.onCommandFinished(e => {
if (e.command.trim().length > 0) {
this._instantiationService.invokeFunction(getCommandHistory)?.add(e.command, { shellType: _ctx.instance.shellType });
}
});
}));
break;
}
}
Expand Down
Loading