* Truncates a long string value in a JSON line for collapsed display. * * @param line - The original line content * @returns Truncated line with ellipsis
(line: string)
| 313 | * @returns Truncated line with ellipsis |
| 314 | */ |
| 315 | function truncateStringLine(line: string): string { |
| 316 | const colonIdx = line.indexOf('":') |
| 317 | if (colonIdx === -1) return line |
| 318 | |
| 319 | const valueStart = line.indexOf('"', colonIdx + 1) |
| 320 | if (valueStart === -1) return line |
| 321 | |
| 322 | const prefix = line.slice(0, valueStart + 1) |
| 323 | const suffix = line.charCodeAt(line.length - 1) === 44 /* ',' */ ? '",' : '"' |
| 324 | const truncated = line.slice(valueStart + 1, valueStart + 1 + MAX_TRUNCATED_STRING_LENGTH) |
| 325 | |
| 326 | return `${prefix}${truncated}...${suffix}` |
| 327 | } |
| 328 | |
| 329 | /** |
| 330 | * Custom hook for managing JSON collapse state and computations. |