MCPcopy Index your code
hub / github.com/coder/code-server / focusTerminal

Method focusTerminal

test/e2e/models/CodeServer.ts:382–401  ·  view source on GitHub ↗

* 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.

()

Source from the content-addressed store, hash-verified

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.

Callers 2

terminal.test.tsFile · 0.80
codeServer.test.tsFile · 0.80

Calls 1

pluralFunction · 0.90

Tested by

no test coverage detected