pretty format: circular reference ids only apply in their own reference tree

so, repeated but not circular data is repeatedly output
helpful for serialisation-like uses and more clear because the id was not printed on the actual data structure in this case
This commit is contained in:
Max Cahill 2021-08-14 19:10:12 +10:00
parent ad8012c89b
commit 2b6a6d8f53

View File

@ -161,6 +161,9 @@ function pretty._process(input, config, processing_state)
--drop depth --drop depth
processing_state.depth = processing_state.depth - 1 processing_state.depth = processing_state.depth - 1
--remove circular
circular_references[input] = nil
local multiline = #chunks > 1 local multiline = #chunks > 1
local separator = (indent == "" or not multiline) and ", " or ",\n"..indent local separator = (indent == "" or not multiline) and ", " or ",\n"..indent
@ -173,4 +176,4 @@ function pretty._process(input, config, processing_state)
return "{" .. prelude .. table.concat(chunks, separator) .. "}" return "{" .. prelude .. table.concat(chunks, separator) .. "}"
end end
return pretty return pretty