From fd8bc8ae3fd7d8b80181ed5467d03df5a9beb416 Mon Sep 17 00:00:00 2001 From: boatbomber Date: Tue, 2 Jan 2024 12:32:37 -0500 Subject: [PATCH] Improve visualization for arrays (#829) --- CHANGELOG.md | 2 ++ .../Components/PatchVisualizer/DisplayValue.lua | 17 ++++++++++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fe6fc377c..8021fac9d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,8 +1,10 @@ # Rojo Changelog ## Unreleased Changes +* Improved the visualization for array properties like Tags ([#829]) * Significantly improved performance of `rojo serve`, `rojo build --watch`, and `rojo sourcemap --watch` on macOS. [#830] +[#829]: https://github.com/rojo-rbx/rojo/pull/829 [#830]: https://github.com/rojo-rbx/rojo/pull/830 ## [7.4.0-rc3] - October 25, 2023 diff --git a/plugin/src/App/Components/PatchVisualizer/DisplayValue.lua b/plugin/src/App/Components/PatchVisualizer/DisplayValue.lua index 439c95d97..a231b879e 100644 --- a/plugin/src/App/Components/PatchVisualizer/DisplayValue.lua +++ b/plugin/src/App/Components/PatchVisualizer/DisplayValue.lua @@ -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