($list, itemsByKey, key, value, extras = {})
| 207 | } |
| 208 | |
| 209 | function updateItemDisplay($list, itemsByKey, key, value, extras = {}) { |
| 210 | const item = itemsByKey.get(key); |
| 211 | if (!item) return; |
| 212 | |
| 213 | if ("value" in extras) { |
| 214 | item.value = extras.value; |
| 215 | } else if (value !== undefined) { |
| 216 | item.value = value; |
| 217 | } |
| 218 | |
| 219 | if ("info" in extras) { |
| 220 | item.info = extras.info; |
| 221 | } |
| 222 | |
| 223 | if ("checkbox" in extras) { |
| 224 | item.checkbox = extras.checkbox; |
| 225 | } |
| 226 | |
| 227 | if ("text" in extras) { |
| 228 | item.text = extras.text; |
| 229 | } |
| 230 | |
| 231 | const $item = $list?.querySelector?.(`[data-key="${key}"]`); |
| 232 | if (!$item) return; |
| 233 | |
| 234 | if (extras.text !== undefined) { |
| 235 | const $text = $item.querySelector(".text"); |
| 236 | if ($text) $text.textContent = extras.text; |
| 237 | } |
| 238 | |
| 239 | const $subtitle = $item.querySelector(".value"); |
| 240 | if ($subtitle) { |
| 241 | $subtitle.textContent = $subtitle.classList.contains("setting-info") |
| 242 | ? String(item.info || "") |
| 243 | : formatValue(item.value); |
| 244 | } |
| 245 | |
| 246 | const $trailingValue = $item.querySelector(".setting-trailing-value"); |
| 247 | if ($trailingValue) { |
| 248 | $trailingValue.textContent = formatValue(item.value); |
| 249 | } |
| 250 | |
| 251 | const $checkbox = $item.querySelector(".input-checkbox"); |
| 252 | if ($checkbox && typeof item.checkbox === "boolean") { |
| 253 | $checkbox.checked = item.checkbox; |
| 254 | } |
| 255 | } |
| 256 | |
| 257 | async function buildSnapshot(serverId) { |
| 258 | const liveServer = lspApi.servers.get(serverId); |
no test coverage detected