fix: prevent premature finalization when text buffer reaches max size

Co-authored-by: aider (openai/andrew/openrouter/deepseek/deepseek-chat-v3.1) <aider@aider.chat>
This commit is contained in:
Andrew Phillips
2025-08-26 20:55:26 -03:00
parent f2161c32f8
commit a92076bbec

View File

@@ -225,11 +225,12 @@ impl MetaPlugin for TextMetaPlugin {
// If it's text, count words and lines for this chunk and stop buffering
self.count_text_stats(&data[..bytes_to_take]);
// If we've reached our buffer limit, drop the buffer and finalize
// If we've reached our buffer limit, drop the buffer but don't finalize yet
// We need to wait for finalize() to be called to output word and line counts
if buffer_len >= self.max_buffer_size {
log::debug!("TEXT: Reached max buffer size, dropping buffer but not finalizing");
self.buffer = None; // Drop the buffer
self.is_finalized = true;
true
false // Don't finalize yet
} else {
false
}