Browse Source

Removes needless closures on setTimeout

main
Eric Amodio 1 year ago
parent
commit
a8ad820342
9 changed files with 10 additions and 16 deletions
  1. +1
    -1
      src/commands/gitCommands.ts
  2. +1
    -1
      src/container.ts
  3. +1
    -3
      src/env/node/git/localGitProvider.ts
  4. +3
    -3
      src/extension.ts
  5. +1
    -1
      src/plus/subscription/serverConnection.ts
  6. +1
    -1
      src/plus/subscription/subscriptionService.ts
  7. +0
    -4
      src/system/function.ts
  8. +1
    -1
      src/webviews/webviewBase.ts
  9. +1
    -1
      src/webviews/webviewViewBase.ts

+ 1
- 1
src/commands/gitCommands.ts View File

@ -178,7 +178,7 @@ export class GitCommandsCommand extends Command {
): Promise<QuickPickStep<QuickPickItem> | QuickInputStep | CustomStep | undefined> {
const stepOrTimeout = await Promise.race([
stepPromise,
new Promise<typeof showLoadingSymbol>(resolve => setTimeout(() => resolve(showLoadingSymbol), 250)),
new Promise<typeof showLoadingSymbol>(resolve => setTimeout(resolve, 250, showLoadingSymbol)),
]);
if (stepOrTimeout !== showLoadingSymbol) {

+ 1
- 1
src/container.ts View File

@ -653,7 +653,7 @@ export class Container {
on: true,
};
// Make sure to delay the execution by a bit so that the configuration changes get propagated first
setTimeout(() => executeCommand(command!, commandArgs), 50);
setTimeout(executeCommand, 50, command, commandArgs);
}
}

+ 1
- 3
src/env/node/git/localGitProvider.ts View File

@ -331,9 +331,7 @@ export class LocalGitProvider implements GitProvider, Disposable {
const location = await any<GitLocation>(findGitPromise, findGitFromSCMPromise);
// Save the found git path, but let things settle first to not impact startup performance
setTimeout(() => {
void this.container.storage.storeWorkspace('gitPath', location.path);
}, 1000);
setTimeout(() => void this.container.storage.storeWorkspace('gitPath', location.path), 1000);
if (scope != null) {
scope.exitDetails = ` ${GlyphChars.Dot} Git (${location.version}) found in ${

+ 3
- 3
src/extension.ts View File

@ -65,7 +65,7 @@ export async function activate(context: ExtensionContext): Promise
sw.stop({ message: ' was NOT activated because GitLens is also enabled' });
// If we don't use a setTimeout here this notification will get lost for some reason
setTimeout(() => void showInsidersErrorMessage(), 0);
setTimeout(showInsidersErrorMessage, 0);
return undefined;
}
@ -86,7 +86,7 @@ export async function activate(context: ExtensionContext): Promise
});
// If we don't use a setTimeout here this notification will get lost for some reason
setTimeout(() => void showPreReleaseExpiredErrorMessage(gitlensVersion, insiders), 0);
setTimeout(showPreReleaseExpiredErrorMessage, 0, gitlensVersion, insiders);
return undefined;
}
@ -213,7 +213,7 @@ export async function activate(context: ExtensionContext): Promise
endTime,
);
setTimeout(() => uninstallDeprecatedAuthentication(), 25000);
setTimeout(uninstallDeprecatedAuthentication, 25000);
return Promise.resolve(api);
}

+ 1
- 1
src/plus/subscription/serverConnection.ts View File

@ -138,7 +138,7 @@ export class ServerConnection implements Disposable {
new Promise<string>((_, reject) =>
this._cancellationSource?.token.onCancellationRequested(() => reject('Cancelled')),
),
new Promise<string>((_, reject) => setTimeout(() => reject('Cancelled'), 120000)),
new Promise<string>((_, reject) => setTimeout(reject, 120000, 'Cancelled')),
]).finally(() => {
this._cancellationSource?.cancel();
this._cancellationSource?.dispose();

+ 1
- 1
src/plus/subscription/subscriptionService.ts View File

@ -532,7 +532,7 @@ export class SubscriptionService implements Disposable {
const validating = this.checkInAndValidateCore(session);
const result = await Promise.race([
validating,
new Promise<boolean>(resolve => setTimeout(() => resolve(true), 3000)),
new Promise<boolean>(resolve => setTimeout(resolve, 3000, true)),
]);
if (result) {

+ 0
- 4
src/system/function.ts View File

@ -173,7 +173,3 @@ export async function sequentialize unknown>(
export function szudzikPairing(x: number, y: number): number {
return x >= y ? x * x + x + y : x + y * y;
}
export async function wait(ms: number) {
await new Promise(resolve => setTimeout(resolve, ms));
}

+ 1
- 1
src/webviews/webviewBase.ts View File

@ -363,7 +363,7 @@ export abstract class WebviewBase implements Disposable {
// It looks like there is a bug where `postMessage` can sometimes just hang infinitely. Not sure why, but ensure we don't hang
return Promise.race<boolean>([
this._panel.webview.postMessage(message),
new Promise<boolean>(resolve => setTimeout(() => resolve(false), 5000)),
new Promise<boolean>(resolve => setTimeout(resolve, 5000, false)),
]);
}
}

+ 1
- 1
src/webviews/webviewViewBase.ts View File

@ -337,7 +337,7 @@ export abstract class WebviewViewBase implements
// It looks like there is a bug where `postMessage` can sometimes just hang infinitely. Not sure why, but ensure we don't hang
return Promise.race<boolean>([
this._view.webview.postMessage(message),
new Promise<boolean>(resolve => setTimeout(() => resolve(false), 5000)),
new Promise<boolean>(resolve => setTimeout(resolve, 5000, false)),
]);
}
}

Loading…
Cancel
Save