Skip to content

Duplicated character when using kitty protocol with swiss french keyboard layout #20522

Description

@lbise

Windows Terminal version

Microsoft.WindowsTerminalCanary 1.26.2182.0

Windows build number

10.0.26100.0

Other Software

WSL Ubuntu 22.04
neovim v0.12.4

Steps to reproduce

Using swiss french keyboard layout
Start WSL/Ubuntu
Start neovim
Typing '!' produces '!!' instead

Expected Behavior

A single key press of ! must produce exactly one printable ! :)

Actual Behavior

A single key press of ! produces !!

I already had several issues with preview but then I noticed that several of them were fixed on master so I switched to canary but I still have this remaining one (the rest were fixed indeed). By the way huge thank you for implementing the kitty protocol ;)
I believe swiss french keyboard does some funky thing related to the "!" key which goes through an unhandled path in windows terminal which leads to it producing the key twice.

To be noted that I do not see this behavior when in a normal ubuntu terminal or if starting tmux. This seems to only appear in applications that use the kitty protocol (i.e. neovim and herdr in my case). After some AI supported research I believe both of these applications enable the ReportEventTypes kitty protocol events.

It suggested this (disclaimer AI generated):

Suspected implementation path

Windows Terminal duplicates ! whenever Kitty ReportEventTypes (flag 2) is enabled. This is reproducible both with Herdr’s flags 7 and Neovim’s flags 3; ReportAlternateKeys is not required to trigger the bug.

Windows Terminal’s source appears to allow unencodable Kitty key-release events to fall back to ordinary printable text:

  • HandleKey() permits key-up processing when ReportEventTypes is enabled
  • _encodeKitty() marks the event as a release and tries getKittyBaseKey()
  • getKittyBaseKey() resolves the unshifted key via ToUnicodeEx()
  • _formatFallback() emits key.codepoint without rejecting key-up events

For this Swiss-French key, deriving the unshifted base key appears to hit a dead-key case. The Kitty release cannot be encoded, then the fallback emits the key-up event’s Unicode
character as a second literal !.

A possible minimal safeguard would be to avoid running the printable fallback for releases:

  if (!_formatEncodingHelper(enc, key, seq) && key.keyDown)
  {
      _formatFallback(kbd, key, seq);
  }

Metadata

Metadata

Labels

Area-InputRelated to input processing (key presses, mouse, etc.)Issue-BugIt either shouldn't be doing this or needs an investigation.Needs-Tag-FixDoesn't match tag requirementsProduct-ConhostFor issues in the Console codebaseProduct-TerminalThe new Windows Terminal.

Type

Projects

Status
To Cherry Pick

Relationships

None yet

Development

No branches or pull requests

Issue actions