Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

setopt HIST_FIND_NO_DUPS breaks history completion #362

Closed
NavyD opened this issue Oct 24, 2021 · 1 comment
Closed

setopt HIST_FIND_NO_DUPS breaks history completion #362

NavyD opened this issue Oct 24, 2021 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@NavyD
Copy link

NavyD commented Oct 24, 2021

An error occurred when typing up after entering [ $PATH = *":$HOME/.local/share/go/bin:": _autocomplete. History_lines: 22: invalid subscript, which may be related to 'setopt HIST_FIND_NO_DUPS'

Environment

  • zsh-autocomplete version: 1c88317
  • zsh version: zsh 5.8 (x86_64-ubuntu-linux-gnu)
  • Plugin manager: zinit
$ git -C ~zsh-autocomplete log --oneline -n1
1c88317 (HEAD -> main, origin/main, origin/HEAD) Suppress a warning

$ print -l $_autocomplete__funcfiletrace
/root/.zinit/bin/zinit.zsh:1612
/root/.zinit/bin/zinit.zsh:2197
/root/.zinit/bin/zinit.zsh:2352

$ print $VENDOR $OSTYPE $SHELL $ZSH_ARGZERO $ZSH_PATCHLEVEL
ubuntu linux-gnu zsh ubuntu/5.8-3ubuntu1

Steps to reproduce

setup docker: docker run --rm -it -v .zshrc_min:/root/.zshrc ubuntu

.zshrc_min
# setopt HIST_FIND_NO_DUPS         # Do not display a line previously found.

### Added by Zinit's installer
if [[ ! -f $HOME/.zinit/bin/zinit.zsh ]]; then
    print -P "%F{33}▓▒░ %F{220}Installing %F{33}DHARMA%F{220} Initiative Plugin Manager (%F{33}zdharma/zinit%F{220})…%f"
    command mkdir -p "$HOME/.zinit" && command chmod g-rwX "$HOME/.zinit"
    command git clone https://github.com/zdharma/zinit "$HOME/.zinit/bin" && \
        print -P "%F{33}▓▒░ %F{34}Installation successful.%f%b" || \
        print -P "%F{160}▓▒░ The clone has failed.%f%b"
fi

source "$HOME/.zinit/bin/zinit.zsh"
autoload -Uz _zinit
(( ${+_comps} )) && _comps[zinit]=_zinit

zinit lucid light-mode for @zinit-zsh/z-a-bin-gem-node

# zsh completions #
zinit wait lucid light-mode for \
        @marlonrichert/zsh-autocomplete \
    atload"_zsh_autosuggest_start" \
        @zsh-users/zsh-autosuggestions \
    blockf atpull'zinit creinstall -q .' \
    mv"src/_mvn -> src/mvn.rm" \
        @zsh-users/zsh-completions \
    atinit"zicompinit; zicdreplay" \
        @zdharma/fast-syntax-highlighting
### End of Zinit's installer chunk

Steps

# run in docker
$ apt update && apt install -y git curl zsh
$ zsh
#...

$ echo 'hello'
hello
$ echo $HOME
/root
$ echo 'hello' # press up
hello
$ [ $PATH = *":$HOME/.local/share/go/bin:"
zsh: no matches found: *:/root/.local/share/go/bin:
$ echo 'hello' # press up
hello
$ [ $PATH = *":$HOME/.local/share/go/bin:" # press up
zsh: no matches found: *:/root/.local/share/go/bin:
$ echo 'hello' # press up
hello
$ setopt HIST_FIND_NO_DUPS
$ # a error occurs when pressing up
_autocomplete.history_lines:22: invalid subscript

I tried functions -t _autocomplete.history_lines mentioned in #280

functions -t _autocomplete.history_lines output
$ functions -t _autocomplete.history_lines
$ +_autocomplete.history_lines:1> local -P tag=history-lines
+_autocomplete.history_lines:2> _tags history-lines
+_tags:3> local prev
+_tags:10> [[ history-lines = -- ]]
+_tags:15> ((  1  ))
+_tags:19> local curcontext=history-search:autocomplete.history-lines:: order tag nodef tmp
+_tags:21> [[ history-lines = -C?* ]]
+_tags:24> [[ history-lines = -C ]]
+_tags:29> [[ history-lines = -(|-) ]]
+_tags:31> zstyle -a :completion:history-search:autocomplete.history-lines::: group-order order
+_tags:32> compgroups expansions options globbed-files local-directories directories executables suffix-aliases aliases functions builtins reserved-words commands
+_tags:36> comptags -i history-search:autocomplete.history-lines:: history-lines
+_tags:40> [[ -n '' ]]
+_tags:43> zstyle -a :completion:history-search:autocomplete.history-lines::: tag-order order
+_tags:44> ((  ! 0  ))
+_tags:55> [[ -z '' ]]
+_tags:55> comptry history-lines
+_tags:60> comptags -T
+_tags:62> return
+_autocomplete.history_lines:3> _tags
+_tags:3> local prev
+_tags:10> [[ '' = -- ]]
+_tags:15> ((  0  ))
+_tags:67> comptags -N
+_autocomplete.history_lines:5> _requested history-lines
+_requested:3> local __gopt
+_requested:5> __gopt=( )
+_requested:6> zparseopts -D -a __gopt 1 2 V J x
+_requested:8> comptags -R history-lines
+_requested:9> [[ 1 -gt 3 ]]
+_requested:11> [[ 1 -gt 1 ]]
+_requested:14> return 0
+_autocomplete.history_lines:8> local -PA events=( )
+_autocomplete.history_lines:9> local -Pi min_lines='' max_lines=''
+_autocomplete.history_lines:10> zstyle -s :autocomplete:history-search:autocomplete.history-lines::: list-lines min_lines
+_autocomplete.history_lines:11> min_lines=16
+_autocomplete.history_lines:12> ((  max_lines = min( min_lines, HISTNO - 1, LINES - BUFFERLINES ) +zsh_math_func_min:1> local result=16
+zsh_math_func_min:2> shift
+zsh_math_func_min:3> local arg
+zsh_math_func_min:4> arg=10
+zsh_math_func_min:5> ((  10 < result  ))
+zsh_math_func_min:5> result=10
+zsh_math_func_min:4> arg=30
+zsh_math_func_min:5> ((  30 < result  ))
+zsh_math_func_min:7> ((  result  ))
 ))
+_autocomplete.history_lines:14> [[ -z '' ]]
+_autocomplete.history_lines:15> [[ history-search:autocomplete.history-lines:: == *-forward:* ]]
+_autocomplete.history_lines:18> local -Pi inc=-1 histno=10
+_autocomplete.history_lines:20> [[ -o histfindnodups ]]
+_autocomplete.history_lines:21> ((  0 < max_lines && 0 < histno && histno < HISTNO  ))
+_autocomplete.history_lines:22> [[ -v 'history[10]' && ! -v 'events[functions -t _autocomplete.history_lines]' ]]
+_autocomplete.history_lines:23> events[$history[$histno]]=10
+_autocomplete.history_lines:24> ((  histno += inc  ))
+_autocomplete.history_lines:21> ((  1 < max_lines && 0 < histno && histno < HISTNO  ))
+_autocomplete.history_lines:22> [[ -v 'history[9]' && ! -v 'events[setopt HIST_FIND_NO_DUPS]' ]]
+_autocomplete.history_lines:23> events[$history[$histno]]=9
+_autocomplete.history_lines:24> ((  histno += inc  ))
+_autocomplete.history_lines:21> ((  2 < max_lines && 0 < histno && histno < HISTNO  ))
+_autocomplete.history_lines:22> [[ -v 'history[8]' && ! -v 'events[echo '\''hello'\'']' ]]
+_autocomplete.history_lines:23> events[$history[$histno]]=8
+_autocomplete.history_lines:24> ((  histno += inc  ))
+_autocomplete.history_lines:21> ((  3 < max_lines && 0 < histno && histno < HISTNO  ))

+_autocomplete.history_lines:22> [[ -v 'history[7]' && ! -v 'events[[ $PATH = *":$HOME/.local/share/go/bin:"]'_autocomplete.history_lines:22: invalid subscript
 ]]
@NavyD NavyD added the bug Something isn't working label Oct 24, 2021
@marlonrichert marlonrichert self-assigned this Oct 26, 2021
@marlonrichert
Copy link
Owner

@NavyD It's fixed. PS: If you enjoy using my software, please consider sponsoring me. 🙂

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 28, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants