Merge changes I829581a3,I0016970d,I5dac8e77,Ib7560fe5 into main
* changes: doc/release-notes: add for pretty printing improvements libexpr/print: do not show elided nested items when there are none libexpr/print: never show empty attrsets or derivations as «repeated» libexpr/print: pretty-print idempotently
This commit is contained in:
+16
-9
@@ -264,22 +264,24 @@ private:
|
||||
return true;
|
||||
}
|
||||
|
||||
if (options.force) {
|
||||
// The item is going to be forced during printing anyway, but we need its type now.
|
||||
state.forceValue(*item, item->determinePos(noPos));
|
||||
}
|
||||
|
||||
// Pretty-print single-item attrsets only if they contain nested
|
||||
// structures.
|
||||
auto itemType = item->type();
|
||||
return itemType == nList || itemType == nAttrs || itemType == nThunk;
|
||||
return itemType == nList || itemType == nAttrs;
|
||||
}
|
||||
|
||||
void printAttrs(Value & v, size_t depth)
|
||||
{
|
||||
if (seen && !seen->insert(v.attrs).second) {
|
||||
printRepeated();
|
||||
return;
|
||||
}
|
||||
|
||||
if (options.force && options.derivationPaths && state.isDerivation(v)) {
|
||||
printDerivation(v);
|
||||
} else if (depth < options.maxDepth) {
|
||||
} else if (seen && !v.attrs->empty() && !seen->insert(v.attrs).second) {
|
||||
printRepeated();
|
||||
} else if (depth < options.maxDepth || v.attrs->empty()) {
|
||||
increaseIndent();
|
||||
output << "{";
|
||||
|
||||
@@ -335,10 +337,15 @@ private:
|
||||
return true;
|
||||
}
|
||||
|
||||
if (options.force) {
|
||||
// The item is going to be forced during printing anyway, but we need its type now.
|
||||
state.forceValue(*item, item->determinePos(noPos));
|
||||
}
|
||||
|
||||
// Pretty-print single-item lists only if they contain nested
|
||||
// structures.
|
||||
auto itemType = item->type();
|
||||
return itemType == nList || itemType == nAttrs || itemType == nThunk;
|
||||
return itemType == nList || itemType == nAttrs;
|
||||
}
|
||||
|
||||
void printList(Value & v, size_t depth)
|
||||
@@ -348,7 +355,7 @@ private:
|
||||
return;
|
||||
}
|
||||
|
||||
if (depth < options.maxDepth) {
|
||||
if (depth < options.maxDepth || v.listSize() == 0) {
|
||||
increaseIndent();
|
||||
output << "[";
|
||||
auto listItems = v.listItems();
|
||||
|
||||
Reference in New Issue
Block a user