@@ -362,10 +362,10 @@ static vector<Item> CreateStringGroups(const vector<Item>& items)
362
362
if (i.type == StringSeparator && !i.tokens .empty ())
363
363
{
364
364
// We try to push separators onto a preceding word, otherwise treat as
365
- // a singular atom
365
+ // a singular string component
366
366
if (pending.empty ())
367
367
{
368
- result.push_back (Item {Atom , {}, {i.tokens }, 0 });
368
+ result.push_back (Item {StringComponent , {}, {i.tokens }, 0 });
369
369
}
370
370
else
371
371
{
@@ -378,7 +378,8 @@ static vector<Item> CreateStringGroups(const vector<Item>& items)
378
378
}
379
379
else if (i.type == StringWhitespace)
380
380
{
381
- // Special case because we let whitespace trail even if over width
381
+ // Whitespace is allowed to exceed width without wrapping, so we use a special
382
+ // type for it.
382
383
if (!pending.empty ())
383
384
{
384
385
result.push_back (Item {StringComponent, pending, {}, 0 });
@@ -395,17 +396,17 @@ static vector<Item> CreateStringGroups(const vector<Item>& items)
395
396
result.push_back (Item {StringComponent, pending, {}, 0 });
396
397
pending.clear ();
397
398
}
398
- result.push_back (Item { Atom , i.items , i.tokens , i.width });
399
+ result.push_back (Item { StringComponent , i.items , i.tokens , i.width });
399
400
}
400
-
401
401
else if (i.type == StartOfContainer && pending.empty ())
402
402
{
403
403
result.push_back (i);
404
404
}
405
405
else if (i.type == EndOfContainer && hasStrings && !pending.empty ())
406
406
{
407
- result.push_back (Item {StringComponent , pending, {}, 0 });
407
+ result.push_back (Item {Group , pending, {}, 0 });
408
408
result.push_back (i);
409
+ pending.clear ();
409
410
}
410
411
else
411
412
{
@@ -748,16 +749,16 @@ vector<DisassemblyTextLine> GenericLineFormatter::FormatLines(
748
749
size_t desiredStringWidth = settings.stringWrappingWidth ;
749
750
if (indentation < settings.desiredLineLength )
750
751
{
751
- size_t remainingStringWidth = desiredStringWidth - indentation;
752
- if (remainingStringWidth > desiredStringWidth )
752
+ size_t remainingStringWidth = settings. desiredLineLength - indentation;
753
+ if (remainingStringWidth > desiredWidth )
753
754
desiredStringWidth = remainingStringWidth;
754
755
}
755
756
756
757
// Compute target width for continuation string wrapping lines
757
758
size_t desiredStringContinuationWidth = settings.stringWrappingWidth ;
758
759
if (continuationIndentation < settings.desiredLineLength )
759
760
{
760
- size_t remainingStringWidth = desiredStringContinuationWidth - continuationIndentation;
761
+ size_t remainingStringWidth = settings. desiredLineLength - continuationIndentation;
761
762
if (remainingStringWidth > desiredStringContinuationWidth)
762
763
desiredStringContinuationWidth = remainingStringWidth;
763
764
}
@@ -779,8 +780,7 @@ vector<DisassemblyTextLine> GenericLineFormatter::FormatLines(
779
780
{
780
781
case BraceToken:
781
782
// Beginning of string
782
- if (tokenIndex + 1 < currentLine.tokens .size ()
783
- && currentLine.tokens [tokenIndex + 1 ].type == StringToken)
783
+ if (trimmedText == " \" " && currentLine.tokens [tokenIndex + 1 ].type == StringToken)
784
784
{
785
785
// Create a ContainerContents item and place it onto the item stack. This will hold anything
786
786
// inside the container once the end of the container is found.
@@ -792,14 +792,18 @@ vector<DisassemblyTextLine> GenericLineFormatter::FormatLines(
792
792
items.push_back (Item {StartOfContainer, {}, {token}, 0 });
793
793
}
794
794
// End of string
795
- else if (currentLine.tokens [tokenIndex].type == StringToken
796
- && tokenIndex + 1 < currentLine.tokens .size ()
797
- && currentLine.tokens [tokenIndex + 1 ].type == BraceToken)
795
+ else if (trimmedText == " \" " && currentLine.tokens [tokenIndex - 1 ].type == StringToken)
798
796
{
799
- // Create a ContainerContents item and place it onto the item stack. This will hold anything
800
- // inside the container once the end of the container is found.
801
- items.push_back (Item {Container, {}, {}, 0 });
802
- itemStack.push (items);
797
+ items.push_back (Item {EndOfContainer, {}, {token}, 0 });
798
+
799
+ if (itemStack.empty ())
800
+ break ;
801
+
802
+ // Go back up the item stack and add the items to the container
803
+ vector<Item> parent = itemStack.top ();
804
+ itemStack.pop ();
805
+ parent.back ().items .insert (parent.back ().items .end (), items.begin (), items.end ());
806
+ items = parent;
803
807
}
804
808
else if (trimmedText == " (" || trimmedText == " [" || trimmedText == " {" )
805
809
{
0 commit comments