summaryrefslogtreecommitdiff
path: root/xmake/modules/private/utils/complete.lua
diff options
context:
space:
mode:
authorOpportunityLiu <[email protected]>2019-06-05 21:43:43 +0800
committerOpportunityLiu <[email protected]>2019-06-05 21:43:43 +0800
commit28f861f08f77436d8085b3395f692eb421eae239 (patch)
tree2b9bb61179c645cbd9d849ef01c083da90bbaf60 /xmake/modules/private/utils/complete.lua
parent2fc0ed7ad1d2af134d1b25334634f1050bb42376 (diff)
fix
Diffstat (limited to 'xmake/modules/private/utils/complete.lua')
-rw-r--r--xmake/modules/private/utils/complete.lua17
1 files changed, 12 insertions, 5 deletions
diff --git a/xmake/modules/private/utils/complete.lua b/xmake/modules/private/utils/complete.lua
index df3e98e3f..cf6123dec 100644
--- a/xmake/modules/private/utils/complete.lua
+++ b/xmake/modules/private/utils/complete.lua
@@ -22,11 +22,13 @@
import("core.base.option")
import("core.base.task")
-local tasks = task.tasks()
+local tasks = {}
local shortnames = {}
-for k, v in pairs(tasks) do
- if v.shortname then
- shortnames[menu.shortname] = k
+for _, v in ipairs(task.tasks()) do
+ local menu = option.taskmenu(v)
+ tasks[v] = menu
+ if menu.shortname then
+ shortnames[menu.shortname] = v
end
end
@@ -82,6 +84,11 @@ function _complete_option(options, name)
_print_candidate((v[3] == "k") and "-%s" or "-%s ", v[1])
end
end
+
+ if name == "" then
+ return
+ end
+
for _, v in ipairs(opcandi) do
-- not startswith
if (state == 2 or state == 0) and v[2]:find(name, 2, true) then
@@ -116,6 +123,6 @@ function main(position, ...)
table.insert(segs, 1, task)
task = "run"
end
- _complete_option(option.taskmenu(task).options, has_space and "" or segs[#segs])
+ _complete_option(tasks[task].options, has_space and "" or segs[#segs])
return
end \ No newline at end of file