For a grammar cmd (--foo | {{{ echo bar }}});, the {{{ echo bar }}} command is executed even when we're matching the first word (i.e. cmd <TAB>), which is premature. {{{ echo bar }}} should be executed lazily only after we know --foo hasn't matched.
The output currently produced:
__complgen_jit () {
local -a matches=()
local -a completions=("bar" "foo")
compadd -Q -a completions
compadd -O matches -a completions
[[ ${#matches} -gt 0 ]] && return
}
__complgen_jit
whereas it should look more like (in this case for ZSH)
__complgen_jit () {
local -a matches=()
local -a completions=("foo")
compadd -Q -a completions
compadd -O matches -a completions
[[ ${#matches} -gt 0 ]] && return
completions=("${(@f)$(echo bar)}")
compadd -Q -a completions
compadd -O matches -a completions
[[ ${#matches} -gt 0 ]] && return
}
__complgen_jit
For a grammar
cmd (--foo | {{{ echo bar }}});
, the{{{ echo bar }}}
command is executed even when we're matching the first word (i.e.cmd <TAB>
), which is premature.{{{ echo bar }}}
should be executed lazily only after we know--foo
hasn't matched.The output currently produced:
whereas it should look more like (in this case for ZSH)
This piece of code is responsible for generating those completions: https://github.com/adaszko/complgen/blob/5e29dcbf46840bd9eb0599dcf737ce786d26340c/src/jit.rs#L395-L400