Skip to content

[BUG] Can't bind text object key #326

@ittayd

Description

@ittayd

General information

Basic examination

  • [V] I have read through the README page
  • [V] I have the latest version of zsh-vi-mode
  • [V] I have tested with another terminal program

Problem description

bindkey in viopp doesn't work ZVM_LAZY_KEYBINDINGS set to false. if ZVM_LAZY_KEYBINDINGS is not set to false, then if i go to normal mode then load the bindkey, things work.

Reproduction steps

1. in .zshrc
function zvm_config() {
  # Always start each new prompt in INSERT (optional but nice)
  ZVM_LINE_INIT_MODE=$ZVM_MODE_INSERT
  # IMPORTANT: use the ZLE engine so viopp bindings work reliably
  ZVM_READKEY_ENGINE=$ZVM_READKEY_ENGINE_ZLE
}

function zvm_after_lazy_keybindings() {
  zt light-mode for baodrate/vi-motions
}

ZVM_LAZY_KEYBINDINGS=false
zinit lucid light-mode for jeffreytse/zsh-vi-mode 

2. create the file /tmp/test:
zvm_test_around() {
  echo hi > /tmp/hi
}

zle -N zvm_test_around

for m in visual viopp; do
  bindkey -M $m 'a/' zvm_test_around
done

3. start a new shell:
> . /tmp/test
> foo<esc>da/<ctrl-c>
> cat /tmp/hi
cat: /tmp/hi: No such file or directory

4. start a new shell:
> <esc>i. /tmp/test # that is, go to normal, then insert, then source the file
> foo<esc>da/<ctrl-c>
> cat /tmp/hi
cat: /tmp/hi: No such file or directory

5. comment out the ZVM_LAZY_KEYBINDINGS line in .zshrc

6. repeat 3 & 4 above -> same result

7. add this in .zshrc:
function zvm_after_lazy_keybindings() {
  zinit light-mode for baodrate/vi-motions
}

8. repeat 3: same result

9. repeat 4: works!

10. uncomment  the ZVM_LAZY_KEYBINDINGS line in .zshrc

11. repeat 3: same result

12. repeat 4: doesn't work

Expected behavior

seems like lazy loading vi-motions, when lazy keybingings are off makes binding work if going to normal mode first. this should not be the case. without lazy keybindings my keybindings should work without vi-motions and without going to normal mode first and with they should work without vi-motions

Everything works as expected if I don't load zsh-vi-mode and without vi-motions (so it's not something with zsh)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions