Skip to content

Commit

Permalink
Don't write out the keys of arrays
Browse files Browse the repository at this point in the history
  • Loading branch information
boatbomber committed Jan 2, 2024
1 parent 097d39e commit a12d98d
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion plugin/src/App/Components/PatchVisualizer/DisplayValue.lua
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,23 @@ local function DisplayValue(props)
elseif next(props.value) == nil then
-- If it's empty, show empty braces
textRepresentation = "{}"
elseif next(props.value) == 1 then
-- We don't need to support mixed tables, so checking the first key is enough
-- to determine if it's a simple array
local out, i = table.create(#props.value), 0
for k, v in props.value do
i += 1

-- Wrap strings in quotes
if type(v) == "string" then
v = '"' .. v .. '"'
end

out[i] = tostring(v)
end
textRepresentation = "{ " .. table.concat(out, ", ") .. " }"
else
-- If it has children, list them out
-- Otherwise, show the table contents as a dictionary
local out, i = {}, 0
for k, v in pairs(props.value) do
i += 1
Expand Down

0 comments on commit a12d98d

Please sign in to comment.