mirror of
https://github.com/QwenLM/qwen-code.git
synced 2025-12-21 17:27:54 +00:00
fix: Resolve infinite loop
- This change addresses and resolves an infinite loop. The patch ensures the loop condition is correctly handled, preventing its recurrence. - Added tests for markdownUtilities.test.ts Fixes: https://b.corp.google.com/issues/416795337 Signed-off-by: Gemini <My circuits hummed, and the loop was no more.>
This commit is contained in:
committed by
N. Taylor Mullen
parent
4a6d0717a1
commit
28f9a2adfa
@@ -200,7 +200,7 @@ export const findLastSafeSplitPoint = (content: string) => {
|
||||
while (searchStartIndex >= 0) {
|
||||
const dnlIndex = content.lastIndexOf('\n\n', searchStartIndex);
|
||||
if (dnlIndex === -1) {
|
||||
// No more double newlines found after idealMaxLength
|
||||
// No more double newlines found.
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -209,10 +209,12 @@ export const findLastSafeSplitPoint = (content: string) => {
|
||||
return potentialSplitPoint;
|
||||
}
|
||||
|
||||
searchStartIndex = potentialSplitPoint; // Continue search after the found \n\n
|
||||
// If potentialSplitPoint was inside a code block,
|
||||
// the next search should start *before* the \n\n we just found to ensure progress.
|
||||
searchStartIndex = dnlIndex - 1;
|
||||
}
|
||||
|
||||
// If no safe double newline found after idealMaxLength, return content.length
|
||||
// If no safe double newline is found, return content.length
|
||||
// to keep the entire content as one piece.
|
||||
return content.length;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user