jeffreytse / zsh-vi-mode

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

ZVM conflicts with bracketed paste #238

Open ipkiss42 opened 1 year ago

ipkiss42 commented 1 year ago

General information

Basic examination

Problem description

When bracketed paste is enabled in both zsh (this is the default behavior) and the terminal, pasting a oneliner in insert mode prints the clipboard text (as expected), but also switches to normal mode and flips the case of the character before the cursor (and all the ones after it, if the cursor was not at the end of the line).

This does not happen without bracketed paste. This also doesn't happen without ZVM.

It looks like the \e[201~ sequence at the end of the bracketed paste is intercepted by ZVM, which interprets it as user input. Indeed, after one undo the original text is restored. But of course it is annoying to undo and go back to insert mode every time I paste something...

Reproduction steps

  1. Use a terminal supporting bracketed paste, such as WezTerm
  2. Enable bracketed paste in the shell, if not already on
  3. Place some simple one-liner text in your clipboard, e.g. Hello World
  4. Paste the text in zsh, in insert mode
  5. Observe that the text has become Hello WorlD and that you are in normal mode
  6. Disable bracketed paste, e.g. with unset zle_bracketed_paste. Or disable ZVM instead
  7. Paste the text again
  8. Observe that the text is pasted correctly

Expected behavior

ZVM is "bracketed paste aware" and handles the special sequences gracefully.