% cd $(mktemp -d)
% ZDOTDIR=$PWD HOME=$PWD zsh -f% autoload -Uz compinit
% compinit
% zsh_directory_name() { [[ $1 == c ]] && compadd -S ']' foo }
Given the above setup, when
- $LBUFFER is `cd ~[` or `cd ~[fo`,
- $RBUFFER is empty, and
- I press ^I,
- then $LBUFFER becomes `cd ~[foo]`.
- $LBUFFER is `cd ~[`,
- $RBUFFER is `fo` or `]`, and
- I press ^I,
- then completion beeps and the buffer remains unchanged.
`functions -t _complete` shows that the problem is caused by $compstate[context] becoming `tilde` instead of `subscript` as soon as $SUFFIX is non-empty, which causes _complete() to not call _subscript(), which is the only point of entry to _dynamic_directory_name().