(serverId)
| 498 | } |
| 499 | |
| 500 | export default function lspServerDetail(serverId) { |
| 501 | const initialServer = lspApi.servers.get(serverId); |
| 502 | if (!initialServer) { |
| 503 | toast(strings["lsp-server-not-found"]); |
| 504 | return null; |
| 505 | } |
| 506 | |
| 507 | const directWebSocket = isDirectWebSocketServer( |
| 508 | getMergedConfig(initialServer), |
| 509 | ); |
| 510 | const initialSnapshot = { |
| 511 | liveServer: initialServer, |
| 512 | merged: getMergedConfig(initialServer), |
| 513 | override: getServerOverride(serverId), |
| 514 | directWebSocket, |
| 515 | isCustom: isCustomServer(serverId), |
| 516 | installResult: { |
| 517 | status: "unknown", |
| 518 | version: null, |
| 519 | canInstall: !directWebSocket, |
| 520 | canUpdate: !directWebSocket, |
| 521 | message: strings["lsp-checking-installation-status"], |
| 522 | }, |
| 523 | builtinExts: |
| 524 | getMergedConfig(initialServer).clientConfig?.builtinExtensions || {}, |
| 525 | installCommand: null, |
| 526 | updateCommand: null, |
| 527 | uninstallCommand: null, |
| 528 | }; |
| 529 | |
| 530 | const items = createItems(initialSnapshot); |
| 531 | const itemsByKey = new Map(items.map((item) => [item.key, item])); |
| 532 | const page = settingsPage( |
| 533 | initialServer.label || initialServer.id, |
| 534 | items, |
| 535 | callback, |
| 536 | undefined, |
| 537 | { |
| 538 | preserveOrder: true, |
| 539 | pageClassName: "detail-settings-page", |
| 540 | listClassName: "detail-settings-list", |
| 541 | valueInTail: true, |
| 542 | }, |
| 543 | ); |
| 544 | |
| 545 | const baseShow = page.show.bind(page); |
| 546 | |
| 547 | return { |
| 548 | ...page, |
| 549 | show(goTo) { |
| 550 | baseShow(goTo); |
| 551 | const $list = document.querySelector("#settings .main.list"); |
| 552 | refreshVisibleState($list, itemsByKey, serverId).catch(console.error); |
| 553 | }, |
| 554 | }; |
| 555 | |
| 556 | async function callback(key, value) { |
| 557 | const $list = this?.parentElement; |
no test coverage detected