Skip to content

Commit b1fb9f7

Browse files
author
Akash Satheesan
committed
fix(lib/vscode): add listProcesses to terminal channel
1 parent feb7013 commit b1fb9f7

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

lib/vscode/src/vs/server/node/channel.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -674,6 +674,7 @@ export class TerminalProviderChannel implements IServerChannel<RemoteAgentConnec
674674
case '$getCwd': return this.getTerminalCwd(...args as [number]);
675675
case '$sendCommandResult': return this.sendCommandResultToTerminalProcess(...args as [number, number, boolean, any]);
676676
case '$orphanQuestionReply': return this.orphanQuestionReply(...args as [number]);
677+
case '$listProcesses': return this.listProcesses();
677678
case '$setTerminalLayoutInfo': return this.setTerminalLayoutInfo(args);
678679
case '$getTerminalLayoutInfo': return this.getTerminalLayoutInfo(args);
679680
}
@@ -866,6 +867,20 @@ export class TerminalProviderChannel implements IServerChannel<RemoteAgentConnec
866867
throw new Error('not implemented');
867868
}
868869

870+
private async listProcesses(): Promise<IProcessDetails[]> {
871+
// TODO: args.isInitialization. Maybe this is to have slightly different
872+
// behavior when first listing terminals but I don't know what you'd want to
873+
// do differently. Maybe it's to reset the terminal dispose timeouts or
874+
// something like that, but why not do it each time you list?
875+
const terminals = await Promise.all(Array.from(this.terminals).map(async ([id, terminal]) => {
876+
return terminal.description(id);
877+
}));
878+
879+
// Only returned orphaned terminals so we don't end up attaching to
880+
// terminals already attached elsewhere.
881+
return terminals.filter((t) => t.isOrphan);
882+
}
883+
869884
public async setTerminalLayoutInfo(args: ISetTerminalLayoutInfoArgs): Promise<void> {
870885
this.layouts.set(args.workspaceId, args);
871886
}

0 commit comments

Comments
 (0)