fix: no command completions if query/line is an alias

basically, i have a `c` alias which is `git commit`,
this would resolve to `git commit` literally to try
and complete `commit`, which wouldnt match.
this fixes that, and instead itll suggest commands
that start with `c`. if there is a space after and
completion is requested, itll use the alias properly
insensitive-tab^2
TorchedSammy 2022-04-24 00:06:19 -04:00
parent 4e5f8b5c80
commit 2790982ad1
Signed by: sammyette
GPG Key ID: 904FC49417B44DCD
1 changed files with 5 additions and 1 deletions

View File

@ -6,8 +6,12 @@ function hilbish.completion.handler(line, pos)
local ctx = line:gsub('^%s*(.-)$', '%1')
if ctx:len() == 0 then return {}, '' end
ctx = hilbish.aliases.resolve(ctx)
local res = hilbish.aliases.resolve(ctx)
local resFields = string.split(res, ' ')
local fields = string.split(ctx, ' ')
if #fields > 1 and #resFields > 1 then
fields = resFields
end
local query = fields[#fields]
if #fields == 1 then