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

Initialize shellIntegration and shellIntegration.cwd of existing terminals on startup #237524

Merged
merged 2 commits into from
Jan 8, 2025
Merged
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
25 changes: 18 additions & 7 deletions src/vs/workbench/api/browser/mainThreadTerminalShellIntegration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,18 @@ export class MainThreadTerminalShellIntegration extends Disposable implements Ma
}
}));

// onDidChangeTerminalShellIntegration
// onDidchangeTerminalShellIntegration initial state
for (const terminal of this._terminalService.instances) {
if (terminal.capabilities.has(TerminalCapability.CommandDetection)) {
this._proxy.$shellIntegrationChange(terminal.instanceId);
const cwdDetection = terminal.capabilities.get(TerminalCapability.CwdDetection);
if (cwdDetection) {
this._proxy.$cwdChange(terminal.instanceId, this._convertCwdToUri(cwdDetection.getCwd()));
}
}
}

// onDidChangeTerminalShellIntegration via command detection
const onDidAddCommandDetection = this._store.add(this._terminalService.createOnInstanceEvent(instance => {
return Event.map(
Event.filter(instance.capabilities.onDidAddCapabilityType, e => {
Expand All @@ -43,6 +54,12 @@ export class MainThreadTerminalShellIntegration extends Disposable implements Ma
})).event;
this._store.add(onDidAddCommandDetection(e => this._proxy.$shellIntegrationChange(e.instanceId)));

// onDidChangeTerminalShellIntegration via cwd
const cwdChangeEvent = this._store.add(this._terminalService.createOnInstanceCapabilityEvent(TerminalCapability.CwdDetection, e => e.onDidChangeCwd));
this._store.add(cwdChangeEvent.event(e => {
this._proxy.$cwdChange(e.instance.instanceId, this._convertCwdToUri(e.data));
}));

// onDidStartTerminalShellExecution
const commandDetectionStartEvent = this._store.add(this._terminalService.createOnInstanceCapabilityEvent(TerminalCapability.CommandDetection, e => e.onCommandExecuted));
let currentCommand: ITerminalCommand | undefined;
Expand Down Expand Up @@ -75,12 +92,6 @@ export class MainThreadTerminalShellIntegration extends Disposable implements Ma
});
}));

// onDidChangeTerminalShellIntegration via cwd
const cwdChangeEvent = this._store.add(this._terminalService.createOnInstanceCapabilityEvent(TerminalCapability.CwdDetection, e => e.onDidChangeCwd));
this._store.add(cwdChangeEvent.event(e => {
this._proxy.$cwdChange(e.instance.instanceId, this._convertCwdToUri(e.data));
}));

// Clean up after dispose
this._store.add(this._terminalService.onDidDisposeInstance(e => this._proxy.$closeTerminal(e.instanceId)));
}
Expand Down
Loading