(serverId, partial)
| 37 | } |
| 38 | |
| 39 | export async function updateServerConfig(serverId, partial) { |
| 40 | const key = normalizeServerId(serverId); |
| 41 | if (!key) { |
| 42 | throw new Error("Server id is required"); |
| 43 | } |
| 44 | |
| 45 | const current = cloneLspSettings(); |
| 46 | current.servers = current.servers || {}; |
| 47 | const nextServer = { |
| 48 | ...(current.servers[key] || {}), |
| 49 | }; |
| 50 | |
| 51 | Object.entries(partial || {}).forEach(([entryKey, value]) => { |
| 52 | if (value === undefined) { |
| 53 | delete nextServer[entryKey]; |
| 54 | return; |
| 55 | } |
| 56 | nextServer[entryKey] = value; |
| 57 | }); |
| 58 | |
| 59 | if (Object.keys(nextServer).length) { |
| 60 | current.servers[key] = nextServer; |
| 61 | } else { |
| 62 | delete current.servers[key]; |
| 63 | } |
| 64 | |
| 65 | await appSettings.update({ lsp: current }, false); |
| 66 | } |
| 67 | |
| 68 | export async function upsertCustomServer(serverId, config) { |
| 69 | const key = normalizeServerId(serverId); |
no test coverage detected