@@ -315,21 +315,13 @@ 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
325- string scratch;
326- scratch.reserve (maxParsingLength);
327-
328321 auto ConstructToken = [&](size_t start, size_t end)
329322 {
330- scratch.assign (src.data () + start, end - start);
331323 InstructionTextToken token = unprocessedStringToken;
332- token.text . swap (scratch );
324+ token.text = string (src. substr (start, end - start) );
333325 token.width = token.text .size ();
334326 result.emplace_back (std::move (token));
335327 };
@@ -403,6 +395,20 @@ static vector<InstructionTextToken> ParseStringToken(
403395 {
404396 curEnd++;
405397 }
398+
399+ // Check if we've exceeded max parsing length
400+ if (curEnd > maxParsingLength)
401+ {
402+ // Flush any pending token
403+ flushToken (curStart, maxParsingLength);
404+
405+ // Create single token with remaining text
406+ InstructionTextToken remainingToken = unprocessedStringToken;
407+ remainingToken.text = string (src.substr (maxParsingLength));
408+ remainingToken.width = remainingToken.text .size ();
409+ result.emplace_back (std::move (remainingToken));
410+ return result;
411+ }
406412 }
407413
408414 flushToken (curStart, curEnd);
0 commit comments