* Focuses the integrated terminal by navigating through the command palette. * * This should focus the terminal no matter if it already has focus and/or is * or isn't visible already. It will always create a new terminal to avoid * clobbering parallel tests.
()
| 380 | * clobbering parallel tests. |
| 381 | */ |
| 382 | async focusTerminal() { |
| 383 | const doFocus = async (): Promise<boolean> => { |
| 384 | await this.executeCommandViaMenus("Terminal: Create New Terminal") |
| 385 | try { |
| 386 | await this.page.waitForLoadState("load") |
| 387 | await this.page.waitForSelector("textarea.xterm-helper-textarea:focus-within", { timeout: 5000 }) |
| 388 | return true |
| 389 | } catch (error) { |
| 390 | return false |
| 391 | } |
| 392 | } |
| 393 | |
| 394 | let attempts = 1 |
| 395 | while (!(await doFocus())) { |
| 396 | ++attempts |
| 397 | this.codeServer.logger.debug(`no focused terminal textarea, retrying (${attempts}/∞)`) |
| 398 | } |
| 399 | |
| 400 | this.codeServer.logger.debug(`opening terminal took ${attempts} ${plural(attempts, "attempt")}`) |
| 401 | } |
| 402 | |
| 403 | /** |
| 404 | * Open a file by using menus. |
no test coverage detected