Skip to content

Commit

Permalink
Improve pretty-printing tables with non-string keys
Browse files Browse the repository at this point in the history
and make it more colorful in general
  • Loading branch information
AstroSnail committed Jan 8, 2025
1 parent b1ee724 commit ef523f5
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions pretty-printer.lua
Original file line number Diff line number Diff line change
Expand Up @@ -199,8 +199,16 @@ function PrettyPrint:table(fields, ...)
for k, v in pairs(fields) do
if not hidden_fields[k] then
self:_prefix()
self[#self + 1] = k
self[#self + 1] = self:_color()
if type(k) == "string" then
self[#self + 1] = k
else
self[#self + 1] = "["
self[#self + 1] = self:_resetcolor()
self[#self + 1] = tostring(k)
self[#self + 1] = self:_color()
self[#self + 1] = "]"
end
self[#self + 1] = " = "
self[#self + 1] = self:_resetcolor()
self:any(v, ...)
Expand Down Expand Up @@ -250,8 +258,8 @@ function PrettyPrint:record(kind, fields, ...)
v = hidden_fields[k](v)
end
self:_prefix()
self[#self + 1] = k
self[#self + 1] = self:_color()
self[#self + 1] = k
self[#self + 1] = " = "
self[#self + 1] = self:_resetcolor()
self:any(v, ...)
Expand Down

0 comments on commit ef523f5

Please sign in to comment.