summaryrefslogtreecommitdiff
path: root/xmake/plugins
diff options
context:
space:
mode:
authorruki <[email protected]>2020-12-22 00:54:06 +0800
committerruki <[email protected]>2020-12-22 00:54:06 +0800
commit03ea42dd480b1397394c2363a61b09f438498283 (patch)
tree7fbbfc885d5ca3b179738b2ec8ebcaf8cf993840 /xmake/plugins
parent7d9cc008773b3ee14036778ae0985518951e8c4a (diff)
fix history
Diffstat (limited to 'xmake/plugins')
-rw-r--r--xmake/plugins/macro/main.lua49
1 files changed, 24 insertions, 25 deletions
diff --git a/xmake/plugins/macro/main.lua b/xmake/plugins/macro/main.lua
index 12c8fc6f8..cf0929792 100644
--- a/xmake/plugins/macro/main.lua
+++ b/xmake/plugins/macro/main.lua
@@ -194,40 +194,38 @@ end
function _end(macroname)
-- load the history: cmdlines
- local cmdlines = localcache.get("history", "cmdlines")
+ local cmdlines = table.wrap(localcache.get("history", "cmdlines"))
-- get the last macro block
local begin = false
local block = {}
- if cmdlines then
- local total = #cmdlines
- local index = total
- while index ~= 0 do
+ local total = #cmdlines
+ local index = total
+ while index ~= 0 do
- -- the command line
- local cmdline = cmdlines[index]
+ -- the command line
+ local cmdline = cmdlines[index]
- -- found begin? break it
- if cmdline == "__macro_begin__" then
- begin = true
- break
- end
-
- -- found end? break it
- if cmdline == "__macro_end__" then
- break
- end
+ -- found begin? break it
+ if cmdline == "__macro_begin__" then
+ begin = true
+ break
+ end
- -- ignore "xmake m .." and "xmake macro .."
- if not cmdline:find("xmake%s+macro%s*") and not cmdline:find("xmake%s+m%s*") then
+ -- found end? break it
+ if cmdline == "__macro_end__" then
+ break
+ end
- -- save this command line to block
- table.insert(block, 1, cmdline)
- end
+ -- ignore "xmake m .." and "xmake macro .."
+ if not cmdline:find("xmake%s+macro%s*") and not cmdline:find("xmake%s+m%s*") then
- -- the previous line
- index = index - 1
+ -- save this command line to block
+ table.insert(block, 1, cmdline)
end
+
+ -- the previous line
+ index = index - 1
end
-- the begin tag not found?
@@ -236,7 +234,8 @@ function _end(macroname)
end
-- patch end tag to the history: cmdlines
- localcache.set("history", "cmdlines", "__macro_end__")
+ table.insert(cmdlines, "__macro_end__")
+ localcache.set("history", "cmdlines", cmdlines)
localcache.save("history")
-- open the macro file