Skip to content

Commit 7ad6f90

Browse files
author
Tajudeen
committed
Fix TypeScript nullish error with explicit conditional checks
1 parent e42cf84 commit 7ad6f90

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

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

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -125,10 +125,18 @@ 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 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;
128+
let cwd: URI | string | undefined;
129+
if (override_cwd !== null) {
130+
cwd = override_cwd;
131+
} else {
132+
const workspace = this.workspaceContextService.getWorkspace();
133+
if (workspace.folders.length > 0) {
134+
const firstFolder = workspace.folders[0];
135+
if (firstFolder) {
136+
cwd = firstFolder.uri;
137+
}
138+
}
139+
}
132140

133141
const options: ICreateTerminalOptions = {
134142
cwd,

0 commit comments

Comments
 (0)