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

How to disable autosuggestion when having autocompletion selected? #767

Open
beyond-fu opened this issue Dec 10, 2024 · 2 comments
Open
Labels
bug Something isn't working

Comments

@beyond-fu
Copy link

Environment

% typeset -p1 VENDOR OSTYPE ZSH_PATCHLEVEL _autocomplete__funcfiletrace
<output>
% git -C ~autocomplete log --oneline -n1
<output>
  • Operating system: Fedora41
  • Terminal emulator: Gnome47 default terminal(i.e. Ptyxis)

Steps to reproduce

% cd $(mktemp -d)
% git clone --depth 1 -- https://github.com/marlonrichert/zsh-autocomplete.git
<output>
% > .zshrc <<EOF
setopt interactivecomments transientrprompt
PS1='%# '
PS2=
RPS2='%^'
source $PWD/zsh-autocomplete/zsh-autocomplete.plugin.zsh
EOF
% env -i HOME=$PWD PATH=$PATH TERM=$TERM ${TERMINFO:+TERMINFO=$TERMINFO} zsh -d
% <inputs>
<output>
Contents of ~autocomplete-log/YYYY-MM-DD.log (click to expand)

I saw this issue #576, but it seems to come up again, and changing the order of source zsh-autosuggestion and source zsh-autocompletion. I just installed the latest zsh-autosuggestion and zsh-autocompletion on Fedora41. When I select a completion candidate item, the suggusetion is still there and this is annoying. So I want to know how to make suggestion not showing when one of the completions is selected.

Before enter Tab to complete:
Screenshot From 2024-12-11 01-30-40
After completion:
Screenshot From 2024-12-11 01-30-56

Below is my .zshrc configuration:

if [[ -r "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" ]]; then
  source "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh"
fi

HISTFILE=~/.zsh_histfile
HISTSIZE=1000
SAVEHIST=2000
bindkey -v    
setopt autocd extendedglob nomatch
unsetopt beep notify

# Snap: zsh plugins manager
[[ -r ~/zsh_plugins/znap/znap.zsh ]] ||
    git clone --depth 1 -- \
        https://github.com/marlonrichert/zsh-snap.git ~/zsh_plugins/znap
source ~/zsh_plugins/znap/znap.zsh  # Start Znap

znap source marlonrichert/zsh-autocomplete
znap source zsh-users/zsh-autosuggestions
znap source zsh-users/zsh-syntax-highlighting

source ~/zsh_plugins/powerlevel10k/powerlevel10k.zsh-theme
. "$HOME/.cargo/env"

bindkey "^[[1;5C" "forward-word"
bindkey "^[[1;5D" "backward-word"
bindkey              '^I' menu-select
bindkey "$terminfo[kcbt]" menu-select
bindkey -M menuselect              '^I'         menu-complete
bindkey -M menuselect "$terminfo[kcbt]" reverse-menu-complete
bindkey  "^[[H"   beginning-of-line
bindkey  "^[[F"   end-of-line
bindkey  "^[[3~"  delete-char

zstyle ':autocomplete:*complete*:*' insert-unambiguous yes
zstyle ':autocomplete:*history*:*' insert-unambiguous yes
zstyle ':completion:*:*' matcher-list 'm:{[:lower:]-}={[:upper:]_}' '+r:|[.]=**'

zstyle -e ':autocomplete:*:*' list-lines 'reply=( $(( LINES / 2 )) )'
zstyle ':completion:*:messages' format $'\e[01;35m -- %d -- \e[00;00m'
zstyle ':completion:*:warnings' format $'\e[01;31m -- No Matches Found -- \e[00;00m'
zstyle ':autocomplete:*' ignored-input '..##'

[[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh

Thanks!

@beyond-fu beyond-fu added the bug Something isn't working label Dec 10, 2024
@kaihowl
Copy link

kaihowl commented Dec 21, 2024

I stumbled upon this bug while upgrading to the latest 24.11 (beta) nix release. In my previous configuration with nix 24.05, which I guess uses release 23.07.13, I was able to successfully use autocompletions and autosuggestions in tandem. With the release 24.09.04 I see the behavior from this bug as well. I bisected the regression to commit bbbefed in my case.

@beyond-fu
Copy link
Author

Thanks. But I have switched to fish haha. Fish is out of the box compared to zsh.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants
@kaihowl @beyond-fu and others