AlecAivazis / survey

A golang library for building interactive and accessible prompts with full support for windows and posix terminals.
MIT License
4.07k stars 351 forks source link

Unexpected escape sequence error in vim mode #387

Open cristiand391 opened 2 years ago

cristiand391 commented 2 years ago

I'm getting the error unexpected escape sequence from terminal when I press any key in vim mode using tmux 3.2a. Reproduced this bug on macOS native terminal, Alacritty, also on Xubuntu with xfce4-terminal and Alacritty (clean VM), no config file. This only happens when the program runs inside of tmux.

Example:

  1. Make sure you are using at least tmux 3.2a: tmux -V
  2. Run tmux
  3. Clone cristiand391/survey-tmux-bug
  4. Run go build
  5. Run ./survey-tmux-bug
  6. Press Esc to enter vim mode
  7. Press any key

What operating system and terminal are you using? macOS Big Sur, Xubuntu Alacritty

An example that showcases the bug. Left: Alacritty | Right macOS terminal

survey-tmux-bug-macos

What did you expect to see? It should move the selector when I press j/k.

What did you see instead? unexpected escape sequence

amdprophet commented 2 years ago

This also happens, outside of vim mode, when using key combinations for killing words, moving forwards / backwards by words, etc. E.g.:

Unexpected Escape Sequence: ['\x1b' '\u007f'] (delete one word backwards)
Unexpected Escape Sequence: ['\x1b' 'd'] (delete one word forwards)
Unexpected Escape Sequence: ['\x1b' 'b'] (move backward by one word)
Unexpected Escape Sequence: ['\x1b' 'f'] (move forward by one word)