Skip to content

Commit 168b10d

Browse files
committed
chore: refactor ensureTerminal to return a Terminal
1 parent 237f6b6 commit 168b10d

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

src/client/common/terminal/service.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -141,9 +141,9 @@ export class TerminalService implements ITerminalService, Disposable {
141141
}
142142
}
143143
// TODO: Debt switch to Promise<Terminal> ---> breaks 20 tests
144-
public async ensureTerminal(preserveFocus: boolean = true): Promise<void> {
144+
public async ensureTerminal(preserveFocus: boolean = true): Promise<Terminal> {
145145
if (this.terminal) {
146-
return;
146+
return this.terminal;
147147
}
148148

149149
if (useEnvExtension()) {
@@ -174,7 +174,7 @@ export class TerminalService implements ITerminalService, Disposable {
174174
}
175175

176176
this.sendTelemetry().ignoreErrors();
177-
return;
177+
return this.terminal;
178178
}
179179
private terminalCloseHandler(terminal: Terminal) {
180180
if (terminal === this.terminal) {

src/client/common/terminal/types.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,14 @@ export interface ITerminalService extends IDisposable {
5656
sendText(text: string): Promise<void>;
5757
executeCommand(commandLine: string, isPythonShell: boolean): Promise<TerminalShellExecution | undefined>;
5858
show(preserveFocus?: boolean): Promise<void>;
59+
/**
60+
* Ensures that a terminal exists, creating one if necessary.
61+
*
62+
* @param {boolean} [preserveFocus] Whether the editor should keep focus after the terminal is shown. Defaults to `true`.
63+
* @returns {Promise<Terminal>} The terminal instance.
64+
* @memberof ITerminalService
65+
*/
66+
ensureTerminal(preserveFocus?: boolean): Promise<Terminal>;
5967
}
6068

6169
export const ITerminalServiceFactory = Symbol('ITerminalServiceFactory');

0 commit comments

Comments
 (0)