skywind3000 / z.lua

:zap: A new cd command that helps you navigate faster by learning your habits.
MIT License
3k stars 141 forks source link

Lose order of the completions problem #140

Open timqi opened 3 years ago

timqi commented 3 years ago

https://github.com/skywind3000/z.lua/blob/a3d4f5db684ed6dfd3041e73d1d761f5fe944179/z.lua#L2243

_describe helper will lose the order of completion from zlua, suggest change it to code below for remain the completions order

compadd -U -V zlua "${(@)completions}"

and I'm looking for a way to make z complete like cd when zlua's output is empty:

_zlua_zsh_tab_completion() {
    (( $+compstate )) && compstate[insert]=menu
    local completions=(${(f)"$(_zlua --complete "${words/_zlua/z}")"})

    if [[ ${#completions[@]} == 0 ]]; then
        _files -/
    else
        compadd -U -V zlua "${(@)completions}"
    fi
}

hope @skywind3000 can handle the code merge