Skip to content

Commit 2837e08

Browse files
committed
better fix
1 parent ffa0427 commit 2837e08

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

src/vs/workbench/contrib/tasks/browser/terminalTaskSystem.ts

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,10 @@ interface IReconnectionTaskData {
7878
group?: string;
7979
}
8080

81+
interface IReconnectedTerminal extends ITerminalInstance {
82+
reconnectionData: IReconnectionTaskData;
83+
}
84+
8185
const ReconnectionType = 'Task';
8286

8387
class VariableResolver {
@@ -198,7 +202,7 @@ export class TerminalTaskSystem extends Disposable implements ITaskSystem {
198202
private _terminalCreationQueue: Promise<ITerminalInstance | void> = Promise.resolve();
199203
private _hasReconnected: boolean = false;
200204
private readonly _onDidStateChange: Emitter<ITaskEvent>;
201-
private _reconnectedTerminals: ITerminalInstance[] | undefined;
205+
private _reconnectedTerminals: IReconnectedTerminal[] | undefined;
202206

203207
taskShellIntegrationStartSequence(cwd: string | URI | undefined): string {
204208
return (
@@ -1277,8 +1281,7 @@ export class TerminalTaskSystem extends Disposable implements ITaskSystem {
12771281
}
12781282
for (let i = 0; i < this._reconnectedTerminals.length; i++) {
12791283
const terminal = this._reconnectedTerminals[i];
1280-
const taskForTerminal = terminal.shellLaunchConfig.attachPersistentProcess?.reconnectionProperties?.data as IReconnectionTaskData;
1281-
if (taskForTerminal?.lastTask === task.getCommonTaskId()) {
1284+
if (terminal.reconnectionData.lastTask === task.getCommonTaskId()) {
12821285
this._reconnectedTerminals.splice(i, 1);
12831286
return terminal;
12841287
}
@@ -1323,7 +1326,15 @@ export class TerminalTaskSystem extends Disposable implements ITaskSystem {
13231326
this._logService.trace(`Already reconnected, to ${this._reconnectedTerminals?.length} terminals so returning`);
13241327
return;
13251328
}
1326-
this._reconnectedTerminals = this._terminalService.getReconnectedTerminals(ReconnectionType)?.filter(t => !t.isDisposed && t.shellLaunchConfig.attachPersistentProcess?.reconnectionProperties?.data);
1329+
this._reconnectedTerminals = [];
1330+
for (const terminal of this._terminalService.getReconnectedTerminals(ReconnectionType) || []) {
1331+
const reconnectionData = terminal.shellLaunchConfig.attachPersistentProcess?.reconnectionProperties?.data as IReconnectionTaskData;
1332+
if (reconnectionData) {
1333+
this._reconnectedTerminals.push({ ...terminal, reconnectionData });
1334+
} else {
1335+
this._logService.trace(`Terminal was owned by tasks but has no reconnection data ${terminal.instanceId}, ${JSON.stringify(terminal.shellLaunchConfig)}`);
1336+
}
1337+
}
13271338
this._logService.trace(`Attempting reconnection of ${this._reconnectedTerminals?.length} terminals`);
13281339
if (!this._reconnectedTerminals?.length) {
13291340
this._logService.trace(`No terminals to reconnect to so returning`);

0 commit comments

Comments
 (0)