% 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 1. $LBUFFER is `cd ~[` or `cd ~[fo`, 2. $RBUFFER is empty, and 3. I press ^I, 4. then $LBUFFER becomes `cd ~[foo]`. 1. $LBUFFER is `cd ~[`, 2. $RBUFFER is `fo` or `]`, and 3. I press ^I, 4. 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().