Skip to content

Commit c8f8fe7

Browse files
committed
Fix an error when shortening certain macros (fixes #68)
1 parent d053d7b commit c8f8fe7

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

MacroToolkit/modules/parser.lua

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ local format = string.format
77
local _G = _G
88
local L = MT.L
99
MT.clist = {cast={}, script={}, click={}, console={}, target={}, castsequence={}, stopmacro={}}
10-
10+
local SHOW_META, SHOWTOOLTIP_META = "#show", "#showtooltip"
1111

1212
local GetSpellInfo;
1313
do -- todo: rework after 11.0 release
@@ -189,7 +189,7 @@ local function validateCommandVerb(commandtext, parameters)
189189
local prefix = MT.slash
190190

191191
commandtext = trim(commandtext)
192-
if commandtext == string.sub(_G.SLASH_SHOWTOOLTIP1, 2) or commandtext == string.sub(_G.SLASH_SHOW1, 2) then prefix = "#" end
192+
if commandtext == string.sub(SHOWTOOLTIP_META, 2) or commandtext == string.sub(SHOW_META, 2) then prefix = "#" end
193193
local msg = format("%s: %s%s%s", L["Invalid command"], prefix, cc, commandtext)
194194
--ticket 139
195195
if string.sub(commandtext, 1, 1) == MT.slash then
@@ -231,7 +231,7 @@ local function validateCommandVerb(commandtext, parameters)
231231
msg = format("%s|r", msg)
232232
local matched = findMatch(commandtext, MT.commands)
233233
prefix = MT.slash
234-
if matched == string.sub(_G.SLASH_SHOWTOOLTIP1, 2) or matched == string.sub(_G.SLASH_SHOW1, 2) then prefix = "#" end
234+
if matched == string.sub(SHOWTOOLTIP_META, 2) or matched == string.sub(SHOW_META, 2) then prefix = "#" end
235235
if not p then msg = format("%s\n %s: %s%s|r", msg, L["did you mean"], prefix, matched) end
236236
end
237237
return c, msg
@@ -629,14 +629,14 @@ function MT:ShortenMacro(macrotext)
629629
line = string.gsub(line, "form%s-:%s+", "form:")
630630
s, e, s1, s2 = string.find(line, "%](%a.-);(.-)$")
631631
if s then if s1 == s2 then line = format("%s[]%s", string.sub(line, 1, s), s1) end end
632-
s, e = string.find(line, _G.SLASH_SHOWTOOLTIP1)
632+
s, e = string.find(line, SHOWTOOLTIP_META)
633633
if s then showt = i
634634
else
635-
s, e = string.find(line, _G.SLASH_SHOW1)
635+
s, e = string.find(line, SHOW_META)
636636
if s then show = i end
637637
end
638638
local _, _, command, parameters = MT:ParseMacro(line)
639-
if command == string.sub(_G.SLASH_SHOW1, 2) or command == string.sub(_G.SLASH_SHOWTOOLTIP1, 2) then
639+
if command == string.sub(SHOW_META, 2) or command == string.sub(SHOWTOOLTIP_META, 2) then
640640
if not shows then shows = parameters end
641641
elseif isCast(command) then if not firstc then firstc = parameters end
642642
elseif isScript(command) then
@@ -717,7 +717,7 @@ function MT:ShortenMacro(macrotext)
717717
end
718718
end
719719
if show and showt then table.remove(mout, show) end
720-
if shows and shows == firstc then mout[showt] = _G.SLASH_SHOWTOOLTIP1 end
720+
if firstc and showt and shows and shows:lower() == firstc:lower() then mout[showt] = SHOWTOOLTIP_META end
721721
local mshort = ""
722722
for i, m in ipairs(mout) do mshort = format("%s%s\n", mshort, m) end
723723
mshort = trim(mshort)

0 commit comments

Comments
 (0)