Skip to content

Commit 3875d77

Browse files
author
skywind3000
committed
fixed nushell completion issue
1 parent dff590a commit 3875d77

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

z.lua

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2020,9 +2020,14 @@ function main(argv)
20202020
z_print(M, true, false)
20212021
end
20222022
elseif options['--complete'] then
2023-
local line = args[1] and args[1] or ''
2024-
local head = line:sub(Z_CMD:len()+1):gsub('^%s+', '')
2025-
local M = z_match({head}, Z_METHOD, Z_SUBDIR)
2023+
local M = {}
2024+
if options['-m1'] then
2025+
M = z_match(args and args or {}, Z_METHOD, Z_SUBDIR)
2026+
else
2027+
local line = args[1] and args[1] or ''
2028+
local head = line:sub(Z_CMD:len()+1):gsub('^%s+', '')
2029+
M = z_match({head}, Z_METHOD, Z_SUBDIR)
2030+
end
20262031
for _, item in pairs(M) do
20272032
print(item.name)
20282033
end
@@ -2864,7 +2869,7 @@ $env.config = ($env.config | update hooks.env_change.PWD ($env.config.hooks.env_
28642869
]]
28652870

28662871
local script_complete_nushell = [[
2867-
let zlua_completer = {|spans| $spans | skip 1 | _zlua --complete ...$in | lines | where {|x| $x != $env.PWD}}
2872+
let zlua_completer = {|spans| $spans | skip 1 | _zlua --complete -m1 ...$in | lines | where {|x| $x != $env.PWD}}
28682873
28692874
$env.config = ($env.config | default {} completions)
28702875
$env.config = ($env.config | update completions ($env.config.completions | default {} external))

0 commit comments

Comments
 (0)