summaryrefslogtreecommitdiff
path: root/xmake/modules/private/utils/complete.lua
diff options
context:
space:
mode:
authorOpportunityLiu <[email protected]>2019-06-05 21:15:28 +0800
committerOpportunityLiu <[email protected]>2019-06-05 21:15:28 +0800
commit2fc0ed7ad1d2af134d1b25334634f1050bb42376 (patch)
tree217dd8eab7a5b7aa127da497554f6ca878d9ec9a /xmake/modules/private/utils/complete.lua
parent1b5017a88667c5af7a4afd4311d4861eb540b1bb (diff)
fix for powershell
Diffstat (limited to 'xmake/modules/private/utils/complete.lua')
-rw-r--r--xmake/modules/private/utils/complete.lua10
1 files changed, 5 insertions, 5 deletions
diff --git a/xmake/modules/private/utils/complete.lua b/xmake/modules/private/utils/complete.lua
index 5c85482fb..df3e98e3f 100644
--- a/xmake/modules/private/utils/complete.lua
+++ b/xmake/modules/private/utils/complete.lua
@@ -95,9 +95,9 @@ end
function main(position, ...)
word = table.concat({...}, " ") or ""
position = tonumber(position) or 0
- if position > #word then
- word = word .. " "
- end
+ local has_space = word:endswith(" ") or position > #word
+ word = word:trim()
+
if word:lower():startswith("xmake ") then
word = word:sub(#"xmake " + 1)
end
@@ -107,7 +107,7 @@ function main(position, ...)
local segs = word:split("%s")
local task = table.remove(segs, 1) or ""
- if #segs == 0 and not word:endswith(" ") then
+ if #segs == 0 and not has_space then
if _complete_task(task) then return end
end
@@ -116,6 +116,6 @@ function main(position, ...)
table.insert(segs, 1, task)
task = "run"
end
- _complete_option(option.taskmenu(task).options, word:endswith(" ") and "" or segs[#segs])
+ _complete_option(option.taskmenu(task).options, has_space and "" or segs[#segs])
return
end \ No newline at end of file