()
| 537 | } |
| 538 | |
| 539 | async function openInTerminal() { |
| 540 | try { |
| 541 | const { TerminalManager } = await import( |
| 542 | /* webpackChunkName: "terminal" */ "components/terminal" |
| 543 | ); |
| 544 | const prootPath = convertToProotPath(url); |
| 545 | const terminal = await TerminalManager.createTerminal({ |
| 546 | name: `Terminal - ${name}`, |
| 547 | render: true, |
| 548 | }); |
| 549 | if (terminal?.component) { |
| 550 | const waitForConnection = (timeoutMs = 5000) => |
| 551 | new Promise((resolve, reject) => { |
| 552 | const startTime = Date.now(); |
| 553 | const check = () => { |
| 554 | if (terminal.component.isConnected) { |
| 555 | resolve(); |
| 556 | } else if (Date.now() - startTime > timeoutMs) { |
| 557 | reject(new Error("Terminal connection timeout")); |
| 558 | } else { |
| 559 | setTimeout(check, 50); |
| 560 | } |
| 561 | }; |
| 562 | check(); |
| 563 | }); |
| 564 | await waitForConnection(); |
| 565 | terminal.component.write(`cd ${JSON.stringify(prootPath)}\n`); |
| 566 | Sidebar.hide(); |
| 567 | } |
| 568 | } catch (error) { |
| 569 | console.error("Failed to open terminal:", error); |
| 570 | const errorMsg = error.message || "Unknown error occurred"; |
| 571 | toast(`Failed to open terminal: ${errorMsg}`); |
| 572 | } |
| 573 | } |
| 574 | |
| 575 | async function deleteFile() { |
| 576 | const msg = strings["delete entry"].replace("{name}", name); |
no test coverage detected