zsh-users / zsh-autosuggestions

Fish-like autosuggestions for zsh
MIT License
31.59k stars 1.88k forks source link

Missing space between command and argument when completing with vi-forward-char #528

Open KevCui opened 4 years ago

KevCui commented 4 years ago

Describe the bug

When pressing ESC and then immediately pressing l (vi-forward-char) to finish the completion after a command, the "space" will be removed in-between command and argument.

To Reproduce

Steps to reproduce the behavior:

  1. Prepare a clean .zshrc, include only zsh-augosuggestions widget and enable vi keybinding map :
source ~/.zsh/zsh-autosuggestions/zsh-autosuggestions.zsh
bindkey -v
  1. Start a fresh new terminal, prepare a dummy script:
touch here-is-a-test-script.sh
  1. Run this dummy script at least once to get it in the history:
cd
./here-is-a-test-script.sh .zsh/zsh-autosuggestions
  1. Now start type 'he' to see the suggestion provided as below:

show-suggestion

  1. Press tab to complete script command part:

waiting-for-input

missing-space

correct

It could be some race condition? Not sure, please help to check.

Desktop

bobrippling commented 4 years ago

I'm also seeing this, attempted to bisect but it seems the vi-forward-char functionality is disabled in some commits, so I was only able to narrow it down to a range. Piping the following into git bisect reply should recreate the bisection:

git bisect start
# good: [89dd69d517161f84c7b5858ae7bfde81026d8836] Add pry gem for debugging support
git bisect good 89dd69d517161f84c7b5858ae7bfde81026d8836
# bad: [ae315ded4dba10685dbbafbfa2ff3c1aefeb490d] Merge pull request #494 from zsh-users/develop
git bisect bad ae315ded4dba10685dbbafbfa2ff3c1aefeb490d
# bad: [93877f6b765fc25f52d4104a8049783cdc38b418] We also need to remove the handler when cancelling async request
git bisect bad 93877f6b765fc25f52d4104a8049783cdc38b418
# skip: [be8bba6f388bd9118b0aaf3580c0d3bd97350ed8] Run CI on prominent versions of zsh back to 4.3.11
git bisect skip be8bba6f388bd9118b0aaf3580c0d3bd97350ed8
# skip: [0681a1c12115fd967fcaa0639a18c5df2362a6cb] Remove flaky test that doesn't really matter that much
git bisect skip 0681a1c12115fd967fcaa0639a18c5df2362a6cb
# good: [0c940e70f2eb931c856875bcb15f47b35f37cbec] Don't bind any zle-* methods
git bisect good 0c940e70f2eb931c856875bcb15f47b35f37cbec
# skip: [3136700ccf1fd5fb0a8d66627eed5edd892881dc] Don't fetch suggestions after [up,down]-line-or-beginning-search
git bisect skip 3136700ccf1fd5fb0a8d66627eed5edd892881dc
# skip: [5e4487ed4a04c6559d4cc500e053c0b0d5a1d4af] escape pattern-matching chars on $prefix for match_prev_cmd strategy
git bisect skip 5e4487ed4a04c6559d4cc500e053c0b0d5a1d4af
# skip: [6dfe9c8cd82c0035632857af034030bbb4637c6a] Merge pull request #319 from zsh-users/fixes/async_history
git bisect skip 6dfe9c8cd82c0035632857af034030bbb4637c6a
# skip: [33b91a9dea766d4cbf713e99f46a39cb9841a1da] Merge pull request #268 from thomas-mcdonald/patch-1
git bisect skip 33b91a9dea766d4cbf713e99f46a39cb9841a1da
# good: [c9a51e0c4c604ba7406a4d1ac9fd9164090a3776] Handle dashes at the beginning of commands
git bisect good c9a51e0c4c604ba7406a4d1ac9fd9164090a3776
# bad: [393f7b8bb9d83aef1847d39ad20c6a73849917b8] Fix vi-mode partial-accept
git bisect bad 393f7b8bb9d83aef1847d39ad20c6a73849917b8
# skip: [4ea825faf893e2c596e630a926a9f83629ec7327] Fix #247 and #248 without using `(b)` flag
git bisect skip 4ea825faf893e2c596e630a926a9f83629ec7327
# skip: [680ce21f266d41b4e75f7ceecef4762fb3cd30a5] Merge pull request #275 from zsh-users/fixes/warn_nested_var_opt
git bisect skip 680ce21f266d41b4e75f7ceecef4762fb3cd30a5
# skip: [d6d9a469819c2bddb4d4f1d0d353070af96226e2] Merge pull request #261 from alonhar/patch-1
git bisect skip d6d9a469819c2bddb4d4f1d0d353070af96226e2
# skip: [19ad3ba7cdc288abb83471ffef9c68d0bc0d59b6] Add new 5.5.1 version of zsh to CI
git bisect skip 19ad3ba7cdc288abb83471ffef9c68d0bc0d59b6
# bad: [42f5a06f7f29007d91e37f85e1dc5a80f1b7c059] Need to reset the POSTDISPLAY if exiting early
git bisect bad 42f5a06f7f29007d91e37f85e1dc5a80f1b7c059
# skip: [51fef255dabbf827fc9f5f802a12462770e03153] Add method to connect terminal to tmux session during tests
git bisect skip 51fef255dabbf827fc9f5f802a12462770e03153
# skip: [2cb6eb6e29852e64a146b0284275ecdc0661b082] Merge pull request #218 from zsh-users/develop
git bisect skip 2cb6eb6e29852e64a146b0284275ecdc0661b082
# good: [c52c428793fc4ea2326b9ad0860853959b0d2954] Fix issues with widgets wrapped by other plugins
git bisect good c52c428793fc4ea2326b9ad0860853959b0d2954
# skip: [83129dd796b19cf888dd32aad84753fb728eead9] Make asynchronous suggestions disabled by default
git bisect skip 83129dd796b19cf888dd32aad84753fb728eead9
# skip: [40b96f6cfda900297d8e8c923d6f637f1e37c9f5] Merge pull request #223 from zsh-users/fixes/bpm_async_fix
git bisect skip 40b96f6cfda900297d8e8c923d6f637f1e37c9f5
# good: [c52c428793fc4ea2326b9ad0860853959b0d2954] Fix issues with widgets wrapped by other plugins
git bisect good c52c428793fc4ea2326b9ad0860853959b0d2954

If I were to guess, 42f5a06f7f290 looks like it might have revealed this problem.

niander commented 2 years ago

Also having the same issue. It is actually worse than just eating a space. If you do a forward-char and later delete some characters, not only the space will disappear but after entering a new character it won't be shown. It is there but invisible.

This only happens when the completion suggestion is longer than the line width