Skip to content

Commit 28f5261

Browse files
committed
make timeout setting more consistent with vscode
1 parent 73f3f3c commit 28f5261

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

src/features/terminal/utils.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as path from 'path';
2-
import { Disposable, Terminal, TerminalOptions, Uri } from 'vscode';
2+
import { Disposable, env, Terminal, TerminalOptions, Uri } from 'vscode';
33
import { PythonEnvironment, PythonProject, PythonProjectEnvironmentApi, PythonProjectGetterApi } from '../../api';
44
import { timeout } from '../../common/utils/asyncUtils';
55
import { createSimpleDebounce } from '../../common/utils/debounce';
@@ -21,8 +21,15 @@ export async function waitForShellIntegration(terminal: Terminal): Promise<boole
2121
}
2222

2323
const config = getConfiguration('terminal.integrated');
24+
const shellIntegrationEnabled = config.get<boolean>('shellIntegration.enabled', true);
2425
const timeoutValue = config.get<number | undefined>('shellIntegration.timeout');
25-
const timeoutMs = timeoutValue === undefined || -1 ? 5000 : timeoutValue;
26+
const isRemote = env.remoteName !== undefined;
27+
let timeoutMs: number;
28+
if (typeof timeoutValue !== 'number' || timeoutValue < 0) {
29+
timeoutMs = shellIntegrationEnabled ? 5000 : isRemote ? 3000 : 2000;
30+
} else {
31+
timeoutMs = Math.max(timeoutValue, 500);
32+
}
2633

2734
const disposables: Disposable[] = [];
2835

src/managers/common/utils.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,14 @@ export function noop() {
1313
// do nothing
1414
}
1515

16+
/**
17+
* In **contrast** to just checking `typeof` this will return `false` for `NaN`.
18+
* @returns whether the provided parameter is a JavaScript Number or not.
19+
*/
20+
export function isNumber(obj: unknown): obj is number {
21+
return typeof obj === 'number' && !isNaN(obj);
22+
}
23+
1624
export function shortVersion(version: string): string {
1725
const pattern = /(\d)\.(\d+)(?:\.(\d+)?)?/gm;
1826
const match = pattern.exec(version);

0 commit comments

Comments
 (0)