Skip to content

Commit 6834280

Browse files
committed
fixes #18
1 parent ed0374a commit 6834280

File tree

2 files changed

+45
-12
lines changed

2 files changed

+45
-12
lines changed

DevTool.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -765,7 +765,7 @@ function DevTool:ProcessCallFunctionData(ok, info, parent, args, results)
765765
-- for example 1, 2, nil, 4 should return only this 4 values nothing more, nothing less.
766766
local found = false
767767
for i = 10, 1, -1 do
768-
local result = DevTool.normalizeSecretValue(results[i])
768+
local result = DevTool.secretToString(results[i])
769769
if result ~= nil then
770770
found = true
771771
end

Utilities/Utils.lua

Lines changed: 44 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ end
165165

166166
function DevTool.ToUIString(value, name, withoutLineBrakes)
167167
local result
168-
value = DevTool.normalizeSecretValue(value)
168+
value = DevTool.secretToString(value)
169169
local valueType = type(value)
170170

171171
if valueType == "table" then
@@ -189,9 +189,9 @@ function DevTool.GetObjectInfoFromWoWAPI(helperText, value)
189189
-- try to get frame name
190190
if ok then
191191
local concat = function(str, before, after)
192-
before = DevTool.normalizeSecretValue(before) or ""
193-
after = DevTool.normalizeSecretValue(after) or ""
194-
str = DevTool.normalizeSecretValue(str)
192+
before = DevTool.secretToString(before) or ""
193+
after = DevTool.secretToString(after) or ""
194+
str = DevTool.secretToString(str)
195195
if str then
196196
return resultStr .. " " .. before .. str .. after
197197
end
@@ -203,17 +203,43 @@ function DevTool.GetObjectInfoFromWoWAPI(helperText, value)
203203
local _, text = DevTool.TryCallAPIFn("GetText", value)
204204

205205
local hasSize, left, bottom, width, height = DevTool.TryCallAPIFn("GetBoundsRect", value)
206+
local leftStr, bottomStr, widthStr, heightStr = "", "", "", ""
206207

207208
resultStr = objectType or ""
209+
208210
if hasSize then
211+
if DevTool.isSecret(left) then
212+
leftStr = DevTool.secretToString(left)
213+
else
214+
leftStr = tostring(DevTool.round(left))
215+
end
216+
217+
if DevTool.isSecret(bottom) then
218+
bottomStr = DevTool.secretToString(bottom)
219+
else
220+
bottomStr = tostring(DevTool.round(bottom))
221+
end
222+
223+
if DevTool.isSecret(width) then
224+
widthStr = DevTool.secretToString(width)
225+
else
226+
widthStr = tostring(DevTool.round(width))
227+
end
228+
229+
if DevTool.isSecret(height) then
230+
heightStr = DevTool.secretToString(height)
231+
else
232+
heightStr = tostring(DevTool.round(height))
233+
end
234+
209235
resultStr = concat("[" ..
210-
tostring(DevTool.round(left)) .. ", " ..
211-
tostring(DevTool.round(bottom)) .. ", " ..
212-
tostring(DevTool.round(width)) .. ", " ..
213-
tostring(DevTool.round(height)) .. "]")
236+
leftStr .. ", " ..
237+
bottomStr .. ", " ..
238+
widthStr .. ", " ..
239+
heightStr .. "]")
214240
end
215241

216-
name = DevTool.normalizeSecretValue(name)
242+
name = DevTool.secretToString(name)
217243

218244
if helperText ~= name then
219245
resultStr = concat(name, DevTool.colors.gray:WrapTextInColorCode("<"), DevTool.colors.gray:WrapTextInColorCode(">"))
@@ -290,9 +316,16 @@ function DevTool.GetParentTable(info)
290316
return parent
291317
end
292318

293-
function DevTool.normalizeSecretValue(value)
319+
function DevTool.isSecret(value)
294320
if (issecrettable and issecrettable(value)) or (issecretvalue and issecretvalue(value)) then
321+
return true
322+
end
323+
return false
324+
end
325+
326+
function DevTool.secretToString(value)
327+
if DevTool.isSecret(value) then
295328
return string.format("<SECRET %s>", type(value))
296329
end
297-
return value
330+
return tostring(value)
298331
end

0 commit comments

Comments
 (0)