#!/bin/zsh
local 0=${(%):-%N}

${0}() {
  typeset -g curcontext=${WIDGET}:::
  local +h -a comppostfuncs=( ${(%):-%N}:post "$comppostfuncs[@]" )
  compstate[old_list]=
  autocomplete:_main_complete:new - history-lines _autocomplete__history_lines

  unset curcontext
  (( compstate[nmatches] ))
}

${0}:post() {
  typeset -gi MENUSELECT=0
  compstate[insert]='menu:0'
  if (( compstate[nmatches] < 2 )); then
    compstate[list]=
  fi
}

${0} "$@"
