printList: Force item before determining whether to print multi-line

This commit is contained in:
Robert Hensing 2024-07-14 14:31:20 +02:00
parent a0635a80b2
commit da3eff60bc
2 changed files with 7 additions and 3 deletions

View file

@ -377,6 +377,9 @@ private:
}
}
/**
* @note This may force items.
*/
bool shouldPrettyPrintList(std::span<Value * const> list)
{
if (!options.shouldPrettyPrint() || list.empty()) {
@ -393,6 +396,9 @@ private:
return true;
}
// It is ok to force the item(s) here, because they will be printed anyway.
state.forceValue(*item, item->determinePos(noPos));
// Pretty-print single-item lists only if they contain nested
// structures.
auto itemType = item->type();

View file

@ -14,9 +14,7 @@ Added <number omitted> variables.
layerOne = { ... };
}
[
"https://example.com"
]
[ "https://example.com" ]
[ "https://example.com" ]