jeffreytse / zsh-vi-mode

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

Strange behavior when hitting escape after hitting [cdy] #295

Open Goose97 opened 2 weeks ago

Goose97 commented 2 weeks ago

General information

Basic examination

Problem description

When I perform these key sequence in normal mode:

  1. Hit either c, d or y
  2. Hit Escape

Instead of exiting to normal mode, it enters visual mode.

https://github.com/user-attachments/assets/018ae762-55a8-4fe4-9614-d7b13fb28ea7

Reproduction steps

  1. Make sure you are in normal mode
  2. Hit c (or d, y)
  3. Hit Escape

Expected behavior

Shell should exit to normal mode

Goose97 commented 2 weeks ago

After some git bisect, I believe 11ab44dc207ec8ebdcddd5ab7d77001d83032b54 is the commit that introduced this behavior.

I've tried to tweak it a little bit. Changing these lines fixes the issue. Not sure if it's the correct way to do it.

if [[ $(zvm_escape_non_printed_characters "$keys") =~
  ${ZVM_VI_OPPEND_ESCAPE_BINDKEY/\^\[/\\^\\[} ]]; then
-  return 1
+  return 0 # return 3 works as well
fi