charmbracelet / bubbletea

A powerful little TUI framework 🏗
MIT License
27.24k stars 788 forks source link

fix(windows): Fix coninput not handling control sequences #1041

Closed Sculas closed 3 months ago

Sculas commented 3 months ago

This PR fixes an issue where pressing Enter or Shift+Tab would add a space to the input in huh's input field on Windows.

Before, when emitting a key event containing a control sequence, the character would also be included. The textinput bubble would see this as user input and sanitize it, converting \r to a space and appending it.

Even though this fixes the issue, the real problem lies in the fact that text input is accepted before (all) key binds are processed, presumably because it is assumed that control sequences don't contain any characters (which is the case on Unix, and with this PR now also on Windows). This should be looked into in a separate issue in the huh repository. https://github.com/charmbracelet/huh/pull/284

Thanks @robotastronaut for sharing their research in the Charm Discord server and for the initial fix. In contrast to their fix, this should fully align with the key handling on Unix and fix other issues like Shift+Tab not working on Windows.