mirror of
https://github.com/NixOS/nix
synced 2025-06-28 13:41:15 +02:00
Merge pull request #11100 from NixOS/pretty-print-idempotent
Pretty print idempotently
This commit is contained in:
commit
b23da1ceca
4 changed files with 69 additions and 0 deletions
|
@ -299,6 +299,9 @@ private:
|
|||
output << ANSI_NORMAL;
|
||||
}
|
||||
|
||||
/**
|
||||
* @note This may force items.
|
||||
*/
|
||||
bool shouldPrettyPrintAttrs(AttrVec & v)
|
||||
{
|
||||
if (!options.shouldPrettyPrint() || v.empty()) {
|
||||
|
@ -315,6 +318,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 attrsets only if they contain nested
|
||||
// structures.
|
||||
auto itemType = item->type();
|
||||
|
@ -371,6 +377,9 @@ private:
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @note This may force items.
|
||||
*/
|
||||
bool shouldPrettyPrintList(std::span<Value * const> list)
|
||||
{
|
||||
if (!options.shouldPrettyPrint() || list.empty()) {
|
||||
|
@ -387,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();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue