mirror of
https://github.com/Microsoft/vscode
synced 2024-08-27 13:00:58 +00:00
Merge pull request #186941 from microsoft/tyriar/186922
Prevent the same terminal being reconnected to twice
This commit is contained in:
commit
923091ec96
|
@ -519,7 +519,8 @@ export class PtyService extends Disposable implements IPtyService {
|
|||
performance.mark('code/willGetTerminalLayoutInfo');
|
||||
const layout = this._workspaceLayoutInfos.get(args.workspaceId);
|
||||
if (layout) {
|
||||
const expandedTabs = await Promise.all(layout.tabs.map(async tab => this._expandTerminalTab(args.workspaceId, tab)));
|
||||
const doneSet: Set<number> = new Set();
|
||||
const expandedTabs = await Promise.all(layout.tabs.map(async tab => this._expandTerminalTab(args.workspaceId, tab, doneSet)));
|
||||
const tabs = expandedTabs.filter(t => t.terminals.length > 0);
|
||||
performance.mark('code/didGetTerminalLayoutInfo');
|
||||
return { tabs };
|
||||
|
@ -528,8 +529,8 @@ export class PtyService extends Disposable implements IPtyService {
|
|||
return undefined;
|
||||
}
|
||||
|
||||
private async _expandTerminalTab(workspaceId: string, tab: ITerminalTabLayoutInfoById): Promise<ITerminalTabLayoutInfoDto> {
|
||||
const expandedTerminals = (await Promise.all(tab.terminals.map(t => this._expandTerminalInstance(workspaceId, t))));
|
||||
private async _expandTerminalTab(workspaceId: string, tab: ITerminalTabLayoutInfoById, doneSet: Set<number>): Promise<ITerminalTabLayoutInfoDto> {
|
||||
const expandedTerminals = (await Promise.all(tab.terminals.map(t => this._expandTerminalInstance(workspaceId, t, doneSet))));
|
||||
const filtered = expandedTerminals.filter(term => term.terminal !== null) as IRawTerminalInstanceLayoutInfo<IProcessDetails>[];
|
||||
return {
|
||||
isActive: tab.isActive,
|
||||
|
@ -538,13 +539,17 @@ export class PtyService extends Disposable implements IPtyService {
|
|||
};
|
||||
}
|
||||
|
||||
private async _expandTerminalInstance(workspaceId: string, t: ITerminalInstanceLayoutInfoById): Promise<IRawTerminalInstanceLayoutInfo<IProcessDetails | null>> {
|
||||
private async _expandTerminalInstance(workspaceId: string, t: ITerminalInstanceLayoutInfoById, doneSet: Set<number>): Promise<IRawTerminalInstanceLayoutInfo<IProcessDetails | null>> {
|
||||
try {
|
||||
const oldId = this._getRevivingProcessId(workspaceId, t.terminal);
|
||||
const revivedPtyId = this._revivedPtyIdMap.get(oldId)?.newId;
|
||||
this._logService.info(`Expanding terminal instance, old id ${oldId} -> new id ${revivedPtyId}`);
|
||||
this._revivedPtyIdMap.delete(oldId);
|
||||
const persistentProcessId = revivedPtyId ?? t.terminal;
|
||||
if (doneSet.has(persistentProcessId)) {
|
||||
throw new Error(`Terminal ${persistentProcessId} has already been expanded`);
|
||||
}
|
||||
doneSet.add(persistentProcessId);
|
||||
const persistentProcess = this._throwIfNoPty(persistentProcessId);
|
||||
const processDetails = persistentProcess && await this._buildProcessDetails(t.terminal, persistentProcess, revivedPtyId !== undefined);
|
||||
return {
|
||||
|
|
Loading…
Reference in a new issue