fix: avoid leading-boundary flush before complete boundary

This commit is contained in:
nrslib 2026-03-02 15:14:01 +09:00
parent 872ff5fa36
commit 769bd98724

View File

@ -106,6 +106,11 @@ export class LineTimeSliceBuffer {
? boundaryIndex + 1 ? boundaryIndex + 1
: buffer.length; : buffer.length;
if (!canForceFlush && buffer.length > 0 && this.isBoundary(buffer.charAt(0)) && boundaryIndex < 0) {
this.scheduleTimer(key);
return undefined;
}
const flushText = buffer.slice(0, flushIndex); const flushText = buffer.slice(0, flushIndex);
const remainder = buffer.slice(flushIndex); const remainder = buffer.slice(flushIndex);
this.buffers.set(key, remainder); this.buffers.set(key, remainder);