MCPcopy
hub / github.com/microsoft/vscode / openQuickAccessWithRetry

Method openQuickAccessWithRetry

test/automation/src/quickaccess.ts:140–180  ·  view source on GitHub ↗
(kind: QuickAccessKind, value?: string)

Source from the content-addressed store, hash-verified

138 }
139
140 private async openQuickAccessWithRetry(kind: QuickAccessKind, value?: string): Promise<void> {
141 let retries = 0;
142
143 // Other parts of code might steal focus away from quickinput :(
144 while (retries < 5) {
145
146 try {
147 // Await for quick input widget opened
148 const accept = () => this.quickInput.waitForQuickInputOpened(10);
149 // Open via keybinding
150 switch (kind) {
151 case QuickAccessKind.Files:
152 await this.code.dispatchKeybinding(process.platform === 'darwin' ? 'cmd+p' : 'ctrl+p', accept);
153 break;
154 case QuickAccessKind.Symbols:
155 await this.code.dispatchKeybinding(process.platform === 'darwin' ? 'cmd+shift+o' : 'ctrl+shift+o', accept);
156 break;
157 case QuickAccessKind.Commands:
158 await this.code.dispatchKeybinding(process.platform === 'darwin' ? 'cmd+shift+p' : 'ctrl+shift+p', async () => {
159
160 await this.code.wait(100);
161 await this.quickInput.waitForQuickInputOpened(10);
162 });
163 break;
164 }
165 break;
166 } catch (err) {
167 if (++retries > 5) {
168 throw new Error(`QuickAccess.openQuickAccessWithRetry(kind: ${kind}) failed: ${err}`);
169 }
170
171 // Retry
172 await this.code.dispatchKeybinding('escape', async () => { });
173 }
174 }
175
176 // Type value if any
177 if (value) {
178 await this.quickInput.type(value);
179 }
180 }
181
182 async runCommand(commandId: string, options?: { keepOpen?: boolean; exactLabelMatch?: boolean }): Promise<void> {
183 const keepOpen = options?.keepOpen;

Callers 4

openQuickOutlineMethod · 0.95

Calls 4

dispatchKeybindingMethod · 0.80
typeMethod · 0.65
waitMethod · 0.45

Tested by

no test coverage detected