From 2b6a6d8f5306e45b6c82d640cbc53d7c6bc4cbe5 Mon Sep 17 00:00:00 2001 From: Max Cahill <1bardesign@gmail.com> Date: Sat, 14 Aug 2021 19:10:12 +1000 Subject: [PATCH] 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 --- pretty.lua | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pretty.lua b/pretty.lua index f36a139..016c0e4 100644 --- a/pretty.lua +++ b/pretty.lua @@ -161,6 +161,9 @@ function pretty._process(input, config, processing_state) --drop depth processing_state.depth = processing_state.depth - 1 + --remove circular + circular_references[input] = nil + local multiline = #chunks > 1 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) .. "}" end -return pretty \ No newline at end of file +return pretty