Skip to content

Commit 623e71e

Browse files
committed
Surround wrapped inline strings with bracetokens
1 parent b7291a5 commit 623e71e

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

formatter/generic/genericformatter.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,7 @@ static vector<InstructionTextToken> ParseStringToken(
276276
// Max parsing length set to max annotation length
277277
if (tail > maxParsingLength)
278278
return { unprocessedStringToken };
279+
279280
vector<InstructionTextToken> result;
280281
size_t curStart = 0, curEnd = 0;
281282

@@ -939,13 +940,15 @@ vector<DisassemblyTextLine> GenericLineFormatter::FormatLines(
939940
stack<ItemLayoutStackEntry> layoutStack;
940941
layoutStack.push({items, additionalContinuationIndentation, desiredWidth, desiredContinuationWidth, desiredStringWidth, false});
941942

942-
auto newLine = [&]() {
943+
auto newLine = [&](bool forString = false) {
943944
if (!firstTokenOfLine)
944945
{
945946
string lastTokenText = outputLine.tokens.back().text;
946947
string trimmedText = TrimTrailingWhitespace(lastTokenText);
947948
outputLine.tokens.back().width -= lastTokenText.size() - trimmedText.size();
948949
outputLine.tokens.back().text = trimmedText;
950+
if (forString)
951+
outputLine.tokens.emplace_back(BraceToken, "\"");
949952
}
950953

951954
result.push_back(outputLine);
@@ -960,6 +963,8 @@ vector<DisassemblyTextLine> GenericLineFormatter::FormatLines(
960963
}
961964

962965
outputLine.tokens.emplace_back(TextToken, string(additionalContinuationIndentation, ' '));
966+
if (forString)
967+
outputLine.tokens.emplace_back(BraceToken, "\"");
963968
currentWidth = 0;
964969
desiredWidth = desiredContinuationWidth;
965970
firstTokenOfLine = true;
@@ -987,8 +992,7 @@ vector<DisassemblyTextLine> GenericLineFormatter::FormatLines(
987992
{
988993
// If a string is too wide to fit on the current line, create a newline
989994
// without additional indentation
990-
LogError("Line length vs. desired %zu vs %zu", currentWidth + item->width, desiredStringWidth);
991-
newLine();
995+
newLine(true);
992996
continue;
993997
}
994998
if (currentWidth + item->width > desiredWidth && item->type != StringWhitespace && item->type != StringComponent)

0 commit comments

Comments
 (0)