Fix /amibis spec clear being stored as a spec override
The generic "spec <name>" branch matched before the "spec clear" check, so clearing an override set overrideSpec to "Clear" and the UI then looked for a spec called Clear instead of falling back to auto-detection. Check the clear command first, collapse whitespace so "spec clear" parses, and refresh the frame immediately when the override changes. Spec names are also title-cased per word now, so "/amibis spec beast mastery" resolves to "Beast Mastery". Add test_slash.lua covering set/clear, case/whitespace normalization, and the clear-as-spec-name regression. 93 tests passing.
This commit is contained in:
1 parent
907d274b3a
commit
912ed8f255
4 files changed
+76
-5
No files matched your search
+21
-5
@@ -488,21 +488,37 @@ eventFrame:SetScript("OnEvent", function(self, event, ...)
|
||||
end
|
||||
end)
|
||||
|
||||
local function RefreshUI()
|
||||
if ns.UI and ns.UI.RefreshUI then
|
||||
ns.UI.RefreshUI()
|
||||
end
|
||||
end
|
||||
|
||||
-- Title-case each word so "/amibis spec beast mastery" -> "Beast Mastery".
|
||||
local function NormalizeSpecName(value)
|
||||
return (value:gsub("(%a)([%w']*)", function(first, rest)
|
||||
return first:upper() .. rest:lower()
|
||||
end))
|
||||
end
|
||||
|
||||
SLASH_AMIBIS1 = "/amibis"
|
||||
SlashCmdList["AMIBIS"] = function(msg)
|
||||
local cmd = msg:trim():lower()
|
||||
-- Collapse whitespace so "spec clear" and "spec beast mastery" parse.
|
||||
local cmd = (msg:trim():lower():gsub("%s+", " "))
|
||||
if cmd == "" then
|
||||
Amibis:ToggleFrame()
|
||||
elseif cmd == "spec clear" then
|
||||
AmibisCharDB.overrideSpec = nil
|
||||
print("Amibis: Spec override cleared. Using auto-detected spec.")
|
||||
RefreshUI()
|
||||
elseif cmd:find("^spec%s+") then
|
||||
local spec = cmd:match("^spec%s+(.+)")
|
||||
if spec and spec ~= "" then
|
||||
spec = spec:gsub("^%l", string.upper)
|
||||
spec = NormalizeSpecName(spec)
|
||||
AmibisCharDB.overrideSpec = spec
|
||||
print("Amibis: Spec override set to " .. spec .. ". Type /amibis spec clear to reset.")
|
||||
RefreshUI()
|
||||
end
|
||||
elseif cmd == "spec clear" then
|
||||
AmibisCharDB.overrideSpec = nil
|
||||
print("Amibis: Spec override cleared.")
|
||||
else
|
||||
Amibis:ToggleFrame()
|
||||
end
|
||||
|
||||
Reference in new issue
Block a user