mirror of
https://github.com/Microsoft/vscode
synced 2024-10-02 17:32:41 +00:00
#191860 - retry if command is not found
This commit is contained in:
parent
3e6068253b
commit
7a0fecc0a7
|
@ -254,6 +254,10 @@ export class Code {
|
|||
return this.driver.getLogs();
|
||||
}
|
||||
|
||||
wait(millis: number): Promise<void> {
|
||||
return new Promise((resolve, reject) => setTimeout(resolve, millis));
|
||||
}
|
||||
|
||||
private async poll<T>(
|
||||
fn: () => Promise<T>,
|
||||
acceptFn: (result: T) => boolean,
|
||||
|
|
|
@ -171,15 +171,47 @@ export class QuickAccess {
|
|||
}
|
||||
|
||||
async runCommand(commandId: string, keepOpen?: boolean): Promise<void> {
|
||||
let retries = 0;
|
||||
let error;
|
||||
|
||||
// open commands picker
|
||||
await this.openQuickAccessWithRetry(QuickAccessKind.Commands, `>${commandId}`);
|
||||
while (true) {
|
||||
|
||||
// wait for best choice to be focused
|
||||
await this.quickInput.waitForQuickInputElementFocused();
|
||||
if (++retries > 5) {
|
||||
throw error ?? new Error(`Command: ${commandId} Not found`);
|
||||
}
|
||||
|
||||
// open commands picker
|
||||
await this.openQuickAccessWithRetry(QuickAccessKind.Commands, `>${commandId}`);
|
||||
|
||||
// wait for best choice to be focused
|
||||
await this.quickInput.waitForQuickInputElementFocused();
|
||||
|
||||
// Retry for as long as the command not found
|
||||
const text = await this.quickInput.waitForQuickInputElementText();
|
||||
if (text === 'No matching commands') {
|
||||
this.code.logger.log(`QuickAccess: No matching commands, will retry...`);
|
||||
await this.quickInput.closeQuickInput();
|
||||
await this.code.wait(1000);
|
||||
continue;
|
||||
}
|
||||
|
||||
try {
|
||||
// wait and click on best choice
|
||||
await this.quickInput.selectQuickInputElement(0, keepOpen);
|
||||
} catch (err) {
|
||||
if (keepOpen) {
|
||||
throw err;
|
||||
} else {
|
||||
error = err;
|
||||
this.code.logger.log(`QuickAccess: Probably no matching commands, will retry...`);
|
||||
await this.quickInput.closeQuickInput();
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
// wait and click on best choice
|
||||
await this.quickInput.selectQuickInputElement(0, keepOpen);
|
||||
}
|
||||
|
||||
async openQuickOutline(): Promise<void> {
|
||||
|
|
|
@ -7,7 +7,7 @@ import { Application, Logger } from '../../../../automation';
|
|||
import { installAllHandlers } from '../../utils';
|
||||
|
||||
export function setup(logger: Logger) {
|
||||
describe.skip('Extensions', () => {
|
||||
describe('Extensions', () => {
|
||||
|
||||
// Shared before/after handling
|
||||
installAllHandlers(logger);
|
||||
|
|
|
@ -8,7 +8,7 @@ import { installAllHandlers } from '../../utils';
|
|||
|
||||
export function setup(logger: Logger) {
|
||||
|
||||
describe.skip('Localization', () => {
|
||||
describe('Localization', () => {
|
||||
// Shared before/after handling
|
||||
installAllHandlers(logger);
|
||||
|
||||
|
|
Loading…
Reference in a new issue