(server: LspServerDefinition)
| 672 | } |
| 673 | |
| 674 | async function ensureInstalled(server: LspServerDefinition): Promise<boolean> { |
| 675 | const launcher = server.launcher; |
| 676 | const checkCommand = |
| 677 | launcher?.checkCommand || buildDerivedCheckCommand(server); |
| 678 | if (!checkCommand) return true; |
| 679 | |
| 680 | const cacheKey = getInstallCacheKey(server); |
| 681 | if (!cacheKey) return true; |
| 682 | |
| 683 | // Return cached result if already checked |
| 684 | if (checkedCommands.has(cacheKey)) { |
| 685 | const status = checkedCommands.get(cacheKey); |
| 686 | if (status === STATUS_PRESENT) { |
| 687 | return true; |
| 688 | } |
| 689 | if (status === STATUS_DECLINED) { |
| 690 | return false; |
| 691 | } |
| 692 | checkedCommands.delete(cacheKey); |
| 693 | } |
| 694 | |
| 695 | // If there's already a pending check for this server, wait for it |
| 696 | if (pendingInstallChecks.has(cacheKey)) { |
| 697 | const pending = pendingInstallChecks.get(cacheKey); |
| 698 | if (pending) return pending; |
| 699 | } |
| 700 | |
| 701 | // Create and track the pending promise |
| 702 | const checkPromise = performInstallCheck(server, launcher, cacheKey); |
| 703 | pendingInstallChecks.set(cacheKey, checkPromise); |
| 704 | |
| 705 | try { |
| 706 | return await checkPromise; |
| 707 | } finally { |
| 708 | pendingInstallChecks.delete(cacheKey); |
| 709 | } |
| 710 | } |
| 711 | |
| 712 | interface LoaderDialog { |
| 713 | show: () => void; |
no test coverage detected