Skip to content

Commit ef2c22b

Browse files
committed
Try to follow core syntax for timeout
1 parent f0f4f17 commit ef2c22b

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

src/common/utils/asyncUtils.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
11
export async function sleep(milliseconds: number) {
22
return new Promise<void>((resolve) => setTimeout(resolve, milliseconds));
33
}
4+
5+
export function timeout(ms: number): Promise<void> {
6+
return new Promise((resolve) => setTimeout(resolve, ms));
7+
}
8+
9+
// TODO: Bring timeouts from VS Code: src/vs/base/common/async.ts

src/features/terminal/utils.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import * as path from 'path';
22
import { Disposable, Terminal, TerminalOptions, Uri } from 'vscode';
33
import { PythonEnvironment, PythonProject, PythonProjectEnvironmentApi, PythonProjectGetterApi } from '../../api';
4+
import { timeout } from '../../common/utils/asyncUtils';
45
import { onDidChangeTerminalShellIntegration, onDidWriteTerminalData } from '../../common/window.apis';
56
import { getConfiguration, getWorkspaceFolders } from '../../common/workspace.apis';
67

@@ -27,9 +28,7 @@ export async function waitForShellIntegration(terminal: Terminal): Promise<boole
2728
try {
2829
const result = await Promise.race([
2930
// Condition 1: Shell integration timeout setting
30-
new Promise<boolean>((resolve) => {
31-
setTimeout(() => resolve(false), timeoutMs);
32-
}),
31+
timeout(timeoutMs).then(() => false),
3332

3433
// Condition 2: Shell integration becomes available
3534
new Promise<boolean>((resolve) => {

0 commit comments

Comments
 (0)