Skip to content

Commit 2bea172

Browse files
committed
Parse up until maxParsingLength for large inline strings
1 parent bbb9491 commit 2bea172

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

formatter/generic/genericformatter.cpp

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -315,10 +315,6 @@ static vector<InstructionTextToken> ParseStringToken(
315315
const string_view src = unprocessedStringToken.text;
316316
const size_t tail = src.size();
317317

318-
// Max parsing length set to max annotation length
319-
if (tail > maxParsingLength)
320-
return {unprocessedStringToken};
321-
322318
vector<InstructionTextToken> result;
323319
size_t curStart = 0, curEnd = 0;
324320

@@ -403,6 +399,20 @@ static vector<InstructionTextToken> ParseStringToken(
403399
{
404400
curEnd++;
405401
}
402+
403+
// Check if we've exceeded max parsing length
404+
if (curEnd > maxParsingLength)
405+
{
406+
// Flush any pending token
407+
flushToken(curStart, maxParsingLength);
408+
409+
// Create single token with remaining text
410+
InstructionTextToken remainingToken = unprocessedStringToken;
411+
remainingToken.text = string(src.substr(maxParsingLength));
412+
remainingToken.width = remainingToken.text.size();
413+
result.emplace_back(std::move(remainingToken));
414+
return result;
415+
}
406416
}
407417

408418
flushToken(curStart, curEnd);

0 commit comments

Comments
 (0)