Skip to content

Commit

Permalink
Add fallback to use typename in debugger when no format defined (#3035)
Browse files Browse the repository at this point in the history
* Add fallback to use typename in debugger when no format defined
Fixed bug with table cutting off a single character
Removed ranger debugger format (was just "ranger")

* Remove redundancy
  • Loading branch information
Denneisk authored Apr 10, 2024
1 parent bc614de commit 3179a42
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
5 changes: 2 additions & 3 deletions lua/entities/gmod_wire_expression2/core/table.lua
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ local function temp( ret, tbl, k, v, orientvertical, isnum )
end
end
else
ret = ret .. formatPort[longtype]( v, orientvertical )
ret = ret .. formatPort[longtype](v, orientvertical)
end

if (orientvertical) then
Expand All @@ -105,8 +105,7 @@ WireLib.registerDebuggerFormat( "table", function( value, orientvertical )
if (n > 7) then break end
ret = temp( ret, value, k3, v3, orientvertical, false )
end
ret = ret:Left(-3)
return "{" .. ret .. "}"
return "{" .. ret:sub(1, orientvertical and -2 or -3) .. "}"
end)

--------------------------------------------------------------------------------
Expand Down
9 changes: 5 additions & 4 deletions lua/wire/server/debuggerlib.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
local formatPort = {}
local formatPort = setmetatable({}, { __index = function(_, k)
return function() return k end
end
})

WireLib.Debugger = { formatPort = formatPort } -- Make it global
function formatPort.NORMAL(value)
return string.format("%.3f",value)
Expand Down Expand Up @@ -43,8 +47,6 @@ function formatPort.MATRIX4(value)
return RetText
end

function formatPort.RANGER(value) return "ranger" end

function formatPort.ARRAY(value, OrientVertical)
local RetText = ""
local ElementCount = 0
Expand Down Expand Up @@ -154,7 +156,6 @@ function formatPort.TABLE(value, OrientVertical)
return "{"..RetText.."}"
end


function WireLib.registerDebuggerFormat(typename, func)
formatPort[typename:upper()] = func
end

0 comments on commit 3179a42

Please sign in to comment.