[PR #555] [CLOSED] fix(core): recognize Ctrl+Backspace on Windows Terminal and WSL #1401

Closed
opened 2026-03-14 09:34:41 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/anomalyco/opentui/pull/555
Author: @Info-Cado
Created: 1/19/2026
Status: Closed

Base: mainHead: fix/ctrl-backspace-windows


📝 Commits (3)

  • e452a1f fix(core): recognize Ctrl+Backspace on Windows Terminal and WSL
  • 18363d7 fix(core): use platform detection for backspace handling
  • 91d10f2 fix(core): detect WSL environment for Ctrl+Backspace handling

📊 Changes

2 files changed (+92 additions, -8 deletions)

View changed files

📝 packages/core/src/lib/parse.keypress.test.ts (+63 -4)
📝 packages/core/src/lib/parse.keypress.ts (+29 -4)

📄 Description

Summary

  • Fix Ctrl+Backspace not triggering delete-word-backward on Windows Terminal and WSL

Problem

Windows Terminal and WSL terminals send different byte sequences for backspace:

  • Regular Backspace: \x7f (ASCII 127, DEL)
  • Ctrl+Backspace: \b (ASCII 8)

The current parser treats both as plain backspace without setting ctrl: true, so keybindings like ctrl+backspacedelete-word-backward never trigger.

Additional WSL Complexity

In WSL, process.platform returns 'linux', not 'win32', even though Windows Terminal sends Windows-style key sequences. This required detecting WSL via environment variables (WSL_DISTRO_NAME, WSL_INTEROP).

Solution

Added isWindowsTerminal() helper that detects:

  1. Native Windows (process.platform === 'win32')
  2. WSL (WSL_DISTRO_NAME or WSL_INTEROP environment variables)
Platform \b Handling Result
Windows/WSL Ctrl+Backspace { name: "backspace", ctrl: true }
macOS/Linux Ctrl+H (unchanged) { name: "h", ctrl: true }

Testing

  • All 41 tests pass
  • Tests use the same isWindowsTerminal() helper for platform-aware assertions
  • Manually verified in WSL with Windows Terminal

Fixes anomalyco/opencode#6991


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/anomalyco/opentui/pull/555 **Author:** [@Info-Cado](https://github.com/Info-Cado) **Created:** 1/19/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `fix/ctrl-backspace-windows` --- ### 📝 Commits (3) - [`e452a1f`](https://github.com/anomalyco/opentui/commit/e452a1fdc584daf52cde8f77e64ab34f64bb3429) fix(core): recognize Ctrl+Backspace on Windows Terminal and WSL - [`18363d7`](https://github.com/anomalyco/opentui/commit/18363d75be7108163afec5774b7193ef1b4979c7) fix(core): use platform detection for backspace handling - [`91d10f2`](https://github.com/anomalyco/opentui/commit/91d10f2004ac4117f8a8c8f25d8d126c697540c1) fix(core): detect WSL environment for Ctrl+Backspace handling ### 📊 Changes **2 files changed** (+92 additions, -8 deletions) <details> <summary>View changed files</summary> 📝 `packages/core/src/lib/parse.keypress.test.ts` (+63 -4) 📝 `packages/core/src/lib/parse.keypress.ts` (+29 -4) </details> ### 📄 Description ## Summary - Fix Ctrl+Backspace not triggering `delete-word-backward` on Windows Terminal and WSL ## Problem Windows Terminal and WSL terminals send different byte sequences for backspace: - **Regular Backspace**: `\x7f` (ASCII 127, DEL) - **Ctrl+Backspace**: `\b` (ASCII 8) The current parser treats both as plain backspace without setting `ctrl: true`, so keybindings like `ctrl+backspace` → `delete-word-backward` never trigger. ### Additional WSL Complexity In WSL, `process.platform` returns `'linux'`, not `'win32'`, even though Windows Terminal sends Windows-style key sequences. This required detecting WSL via environment variables (`WSL_DISTRO_NAME`, `WSL_INTEROP`). ## Solution Added `isWindowsTerminal()` helper that detects: 1. Native Windows (`process.platform === 'win32'`) 2. WSL (`WSL_DISTRO_NAME` or `WSL_INTEROP` environment variables) | Platform | `\b` Handling | Result | |----------|-----------------|--------| | Windows/WSL | Ctrl+Backspace | `{ name: "backspace", ctrl: true }` | | macOS/Linux | Ctrl+H (unchanged) | `{ name: "h", ctrl: true }` | ## Testing - All 41 tests pass - Tests use the same `isWindowsTerminal()` helper for platform-aware assertions - Manually verified in WSL with Windows Terminal Fixes anomalyco/opencode#6991 --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-03-14 09:34:41 +03:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/opentui#1401
No description provided.