Skip to content

Commit f64b62c

Browse files
committed
Rename sleep to timeout for better wording consistency
1 parent b7ebab6 commit f64b62c

File tree

3 files changed

+15
-19
lines changed

3 files changed

+15
-19
lines changed

src/common/utils/asyncUtils.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
1-
export async function sleep(milliseconds: number) {
1+
export async function timeout(milliseconds: number): Promise<void> {
22
return new Promise<void>((resolve) => setTimeout(resolve, milliseconds));
33
}
44

5-
export function timeout(ms: number): Promise<void> {
6-
return new Promise((resolve) => setTimeout(resolve, ms));
7-
}
8-
95
// TODO: Advanced timeout from core async: https://github.com/microsoft/vscode-python-environments/issues/953

src/features/terminal/shells/common/shellUtils.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { PythonCommandRunConfiguration, PythonEnvironment } from '../../../../api';
22
import { traceInfo } from '../../../../common/logging';
33
import { getGlobalPersistentState } from '../../../../common/persistentState';
4-
import { sleep } from '../../../../common/utils/asyncUtils';
4+
import { timeout } from '../../../../common/utils/asyncUtils';
55
import { isWindows } from '../../../../common/utils/platformUtils';
66
import { activeTerminalShellIntegration } from '../../../../common/window.apis';
77
import { getConfiguration } from '../../../../common/workspace.apis';
@@ -106,11 +106,11 @@ export function extractProfilePath(content: string): string | undefined {
106106

107107
export async function shellIntegrationForActiveTerminal(name: string, profile?: string): Promise<boolean> {
108108
let hasShellIntegration = activeTerminalShellIntegration();
109-
let timeout = 0;
109+
let timeOutstamp = 0;
110110

111-
while (!hasShellIntegration && timeout < SHELL_INTEGRATION_TIMEOUT) {
112-
await sleep(SHELL_INTEGRATION_POLL_INTERVAL);
113-
timeout += SHELL_INTEGRATION_POLL_INTERVAL;
111+
while (!hasShellIntegration && timeOutstamp < SHELL_INTEGRATION_TIMEOUT) {
112+
await timeout(SHELL_INTEGRATION_POLL_INTERVAL);
113+
timeOutstamp += SHELL_INTEGRATION_POLL_INTERVAL;
114114
hasShellIntegration = activeTerminalShellIntegration();
115115
}
116116

src/test/features/creators/autoFindProjects.unit.test.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1+
import assert from 'assert';
12
import * as path from 'path';
23
import * as sinon from 'sinon';
34
import * as typmoq from 'typemoq';
4-
import * as wapi from '../../../common/workspace.apis';
5-
import * as winapi from '../../../common/window.apis';
6-
import { PythonProjectManager } from '../../../internal.api';
7-
import { createDeferred } from '../../../common/utils/deferred';
8-
import { AutoFindProjects } from '../../../features/creators/autoFindProjects';
9-
import assert from 'assert';
105
import { Uri } from 'vscode';
116
import { PythonProject } from '../../../api';
12-
import { sleep } from '../../../common/utils/asyncUtils';
7+
import { timeout } from '../../../common/utils/asyncUtils';
8+
import { createDeferred } from '../../../common/utils/deferred';
9+
import * as winapi from '../../../common/window.apis';
10+
import * as wapi from '../../../common/workspace.apis';
11+
import { AutoFindProjects } from '../../../features/creators/autoFindProjects';
12+
import { PythonProjectManager } from '../../../internal.api';
1313

1414
suite('Auto Find Project tests', () => {
1515
let findFilesStub: sinon.SinonStub;
@@ -45,7 +45,7 @@ suite('Auto Find Project tests', () => {
4545
const result = await autoFindProjects.create();
4646
assert.equal(result, undefined, 'Result should be undefined');
4747

48-
await Promise.race([deferred.promise, sleep(100)]);
48+
await Promise.race([deferred.promise, timeout(100)]);
4949
assert.ok(errorShown, 'Error message should have been shown');
5050
});
5151

@@ -64,7 +64,7 @@ suite('Auto Find Project tests', () => {
6464
const result = await autoFindProjects.create();
6565
assert.equal(result, undefined, 'Result should be undefined');
6666

67-
await Promise.race([deferred.promise, sleep(100)]);
67+
await Promise.race([deferred.promise, timeout(100)]);
6868
assert.ok(errorShown, 'Error message should have been shown');
6969
});
7070

0 commit comments

Comments
 (0)