jeffreytse / zsh-vi-mode

💻 A better and friendly vi(vim) mode plugin for ZSH.
MIT License
2.93k stars 102 forks source link

Slow on 'J' in NORMAL mode #240

Open piejanssens opened 10 months ago

piejanssens commented 10 months ago

General information

Basic examination

Problem description

Using ZVM_VI_ESCAPE_BINDKEY=jj

Reproduction steps

  1. Press 'jj' to enter NORMAL mode
  2. Press 'k' a number of times to navigate back/up in the history
  3. Press 'j' to navigate down/forward in the history and notice a delay

Expected behavior

'j' should be as fast as 'k' It seems that in NORMAL mode there is a delay after pressing 'j' perhaps because it's waiting if 'j' is pressed again within a certain timeframe (ZVM_VI_ESCAPE_BINDKEY). I would think that this is only necessary in INSERT mode to escape it.

jeffreytse commented 9 months ago

Hi @piejanssens

Thanks for your issue. When you change the escape bindkey of normal mode to jj, it will make a common prefix of j, for j and jj, that's why the readkey engine needs to wait for a specific time ZVM_ESCAPE_TIMEOUT which is 0.3 seconds by default to accept next keystroke, by this way, it can confirm which function the user actually wants.

Thanks & Regards