Skip to content

Commit

Permalink
fix(tablefunctions): remove newlines from empty table formatting (#3028)
Browse files Browse the repository at this point in the history
  • Loading branch information
salinecitrine committed May 18, 2024
1 parent b701f60 commit 7515e36
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions common/tablefunctions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ if not table.toString then
local indent = (options and options.indent) or DEFAULT_INDENT_STEP

local str = "{"
if options and options.pretty then
if #keys > 0 and options and options.pretty then
str = str .. "\n"
end
for i, key in ipairs(keys) do
Expand All @@ -133,9 +133,10 @@ if not table.toString then
if #keys > 0 then
-- remove the last comma (normal) or newline (pretty)
str = str:sub(1, #str - 1)
end
if options and options.pretty then
str = str .. "\n" .. stringRep(" ", _depth * indent)

if options and options.pretty then
str = str .. "\n" .. stringRep(" ", _depth * indent)
end
end
str = str .. "}"

Expand Down

0 comments on commit 7515e36

Please sign in to comment.