| 488 | } |
| 489 | |
| 490 | function stripEcho(data: SessionData, msg: string | undefined, chunk: string): string { |
| 491 | if (!msg) { |
| 492 | return chunk |
| 493 | } |
| 494 | |
| 495 | const set = data.echo.get(msg) |
| 496 | if (!set || set.size === 0) { |
| 497 | return chunk |
| 498 | } |
| 499 | |
| 500 | data.echo.delete(msg) |
| 501 | const list = [...set].sort((a, b) => b.length - a.length) |
| 502 | for (const item of list) { |
| 503 | if (!item || !chunk.startsWith(item)) { |
| 504 | continue |
| 505 | } |
| 506 | |
| 507 | return chunk.slice(item.length).replace(/^\n+/, "") |
| 508 | } |
| 509 | |
| 510 | return chunk |
| 511 | } |
| 512 | |
| 513 | function flushPart(data: SessionData, commits: SessionCommit[], partID: string, interrupted = false) { |
| 514 | const kind = data.part.get(partID) |