zsh-autosuggestions icon indicating copy to clipboard operation
zsh-autosuggestions copied to clipboard

Using vi-mode "right" bind skips the leading slash when completing paths in OhMyZsh

Open niranjankartha opened this issue 4 months ago • 1 comments

Describe the bug

When an autosuggestion for a path is showing, and a trailing slash is suggested by zsh, using the "right" bind in vim to accept the autosuggestion from the plugin, removes the slash suggested by zsh. This does not happen when the "right" arrow key is used.

To Reproduce

Steps to reproduce the behavior:

  1. Enable vim mode in .zshrc. For reference, I am pasting my whole plugins variable from my .zshrc (from OhMyZsh):
plugins=(git vi-mode fzf zsh-autosuggestions)
  1. Ensure that you have completion as an autosuggestion strategy:
ZSH_AUTOSUGGEST_STRATEGY=(completion)
  1. Create the following file structure:
$ tree       
.
└── hello
    └── world

2 directories, 1 file
  1. In insert mode, type file he<tab>. Now, the command line should show:
$ file hello/[world]

where [world] is an autosuggestion from the plugin.

  1. Press <esc> to enter normal mode, and then press l to accept the plugin. The command now goes to:
$ file helloworld

Expected behavior

The completion should include the slash at the end:

$ file hello/world

Screenshots

Autosuggestion for file hello/[world]: Image

Autocompletion to file helloworld after accepting: Image

Desktop

  • OS + distribution: Arch Linux 6.14.9-arch1-1
  • Zsh version: 5.9
  • Plugin version: commit hash 0e810e5afa27acbd074398eefbe28d13005dbc15

Additional context

This appears to be caused because the ending slash after hello is suggested by zsh, which gets deleted when zsh-autosuggest completes the suggestion.

niranjankartha avatar Jun 07 '25 19:06 niranjankartha