Skip to content

Commit e42cf84

Browse files
author
Tajudeen
committed
Fix TypeScript nullish expression error in terminalToolService
1 parent 487dbaa commit e42cf84

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/vs/workbench/contrib/cortexide/browser/terminalToolService.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,10 @@ export class TerminalToolService extends Disposable implements ITerminalToolServ
125125
private async _createTerminal(props: { cwd: string | null, config: ICreateTerminalOptions['config'], hidden?: boolean }) {
126126
const { cwd: override_cwd, config, hidden } = props;
127127

128-
const cwd: URI | string | undefined = (override_cwd ?? undefined) ?? this.workspaceContextService.getWorkspace().folders[0]?.uri;
128+
const workspace = this.workspaceContextService.getWorkspace();
129+
const [firstFolder] = workspace.folders;
130+
const workspaceFolderUri = firstFolder ? firstFolder.uri : undefined;
131+
const cwd: URI | string | undefined = override_cwd !== null ? override_cwd : workspaceFolderUri;
129132

130133
const options: ICreateTerminalOptions = {
131134
cwd,
@@ -216,7 +219,7 @@ export class TerminalToolService extends Disposable implements ITerminalToolServ
216219
throw new Error(`Read Terminal: Terminal with ID ${terminalId} does not exist.`);
217220
}
218221

219-
// Ensure the xterm.js instance has been created otherwise we cannot access the buffer.
222+
// Ensure the xterm.js instance has been created - otherwise we cannot access the buffer.
220223
if (!terminal.xterm) {
221224
throw new Error('Read Terminal: The requested terminal has not yet been rendered and therefore has no scrollback buffer available.');
222225
}

0 commit comments

Comments
 (0)