edit icon indicating copy to clipboard operation
edit copied to clipboard

Holding Esc key causes vt-sequences to leak

Open o-sdn-o opened this issue 6 months ago • 2 comments

Repro:

  • Press and hold Esc
  • Perform any action that generates a vt-sequence, e.g.:
    • Scroll mouse wheel
    • Press F1/../F12/ArrowKeys/Home/End etc.

Tested terminals:

  • GNOME Terminal (Ubuntu 24.04)
  • Windows Terminal (wsl/win32)
  • conhost.exe

o-sdn-o avatar Sep 09 '25 17:09 o-sdn-o

I see the mechanics of this behavior as a case of \x1b+\x1b for the input parser, where the first ESC is always the pressed Esc key. This behavior fires out of the blue in environments like adb shell, where the input is shredded (https://github.com/directvt/vtm/issues/803#issuecomment-3263425204) almost byte by byte.

o-sdn-o avatar Sep 09 '25 20:09 o-sdn-o

Same thing on Alacritty.

If you look here, your bug comes from Token::Esc('\e') being yielded. I imagine another match branch with this would solve that bug:

'\x1b' => {
    return Token::Ctrl('\x1b');
}

axololly avatar Oct 08 '25 20:10 axololly