( container: HTMLElement, displayHtml: string, track: string, previousTrack: string, tableEnd: number, )
| 393 | } |
| 394 | |
| 395 | function patchPostTableTail( |
| 396 | container: HTMLElement, |
| 397 | displayHtml: string, |
| 398 | track: string, |
| 399 | previousTrack: string, |
| 400 | tableEnd: number, |
| 401 | ): boolean { |
| 402 | const postTrack = track.slice(tableEnd); |
| 403 | const prevTableStart = findTableStart(previousTrack); |
| 404 | const prevTableEnd = |
| 405 | prevTableStart === -1 |
| 406 | ? -1 |
| 407 | : firstCompleteTableEnd(previousTrack, prevTableStart); |
| 408 | const prevPostTrack = |
| 409 | prevTableEnd === -1 ? "" : previousTrack.slice(prevTableEnd); |
| 410 | |
| 411 | const firstTable = container.querySelector("table"); |
| 412 | if (!firstTable) { |
| 413 | return false; |
| 414 | } |
| 415 | |
| 416 | const postHolder = ensurePostTableHolder(firstTable); |
| 417 | |
| 418 | if (!postTrack.startsWith(prevPostTrack)) { |
| 419 | postHolder.innerHTML = sanitizeHtml(renderPostTableTrack(postTrack)); |
| 420 | syncStreamingCaret(container, displayHtml, track); |
| 421 | return true; |
| 422 | } |
| 423 | |
| 424 | if (postTrack === prevPostTrack) { |
| 425 | syncStreamingCaret(container, displayHtml, track); |
| 426 | return true; |
| 427 | } |
| 428 | |
| 429 | const patched = patchStreamingHtml( |
| 430 | postHolder, |
| 431 | displayHtml, |
| 432 | postTrack, |
| 433 | prevPostTrack, |
| 434 | ); |
| 435 | if (!patched) { |
| 436 | postHolder.innerHTML = sanitizeHtml(renderPostTableTrack(postTrack)); |
| 437 | } |
| 438 | |
| 439 | syncStreamingCaret(container, displayHtml, track); |
| 440 | return true; |
| 441 | } |
| 442 | |
| 443 | function patchFirstTableStream( |
| 444 | container: HTMLElement, |
no test coverage detected