( serverId: string, runtimeId: string, )
| 92 | } |
| 93 | |
| 94 | export async function setServerRuntime( |
| 95 | serverId: string, |
| 96 | runtimeId: string, |
| 97 | ): Promise<void> { |
| 98 | const normalizedServerId = String(serverId || "") |
| 99 | .trim() |
| 100 | .toLowerCase(); |
| 101 | if (!normalizedServerId) throw new Error("Server id is required"); |
| 102 | |
| 103 | const current = appSettings.value?.lsp || {}; |
| 104 | const currentRuntime = (current.runtime || {}) as RuntimeSettings; |
| 105 | const runtime = { |
| 106 | ...currentRuntime, |
| 107 | servers: { |
| 108 | ...(currentRuntime.servers || {}), |
| 109 | } as Record<string, string>, |
| 110 | }; |
| 111 | const normalizedRuntimeId = toRuntimeId(runtimeId) || AUTO_RUNTIME_ID; |
| 112 | if (normalizedRuntimeId === AUTO_RUNTIME_ID) { |
| 113 | delete runtime.servers[normalizedServerId]; |
| 114 | } else { |
| 115 | runtime.servers[normalizedServerId] = normalizedRuntimeId; |
| 116 | } |
| 117 | |
| 118 | await appSettings.update({ |
| 119 | lsp: { |
| 120 | ...current, |
| 121 | runtime, |
| 122 | }, |
| 123 | }); |
| 124 | } |
| 125 | |
| 126 | export function getDefaultRuntimeSetting(): string { |
| 127 | return toRuntimeId(appSettings.value?.lsp?.runtime?.default) || AUTO_RUNTIME_ID; |
nothing calls this directly
no test coverage detected