Skip to content

fix(cli): restrict ctrl+backspace detection to Windows Terminal only#25882

Closed
dogukanozen wants to merge 4 commits intogoogle-gemini:mainfrom
dogukanozen:fix/backspace-word-delete-non-wt-windows
Closed

fix(cli): restrict ctrl+backspace detection to Windows Terminal only#25882
dogukanozen wants to merge 4 commits intogoogle-gemini:mainfrom
dogukanozen:fix/backspace-word-delete-non-wt-windows

Conversation

@dogukanozen
Copy link
Copy Markdown
Contributor

@dogukanozen dogukanozen commented Apr 23, 2026

Summary

  • PR fix(cli-ui): enable Ctrl+Backspace for word deletion in Windows Terminal #21447 introduced ctrl+backspace word deletion for Windows, but the condition OS === 'Windows_NT' was too broad
  • Previous implementation tried to infer Ctrl+Backspace on Windows using environment heuristics (OS, WT_SESSION)
  • This was unreliable: cmd.exe and PowerShell send \b for plain backspace, causing unintended word deletion
  • Removed ctrl=true inference entirely
  • \b is now consistently treated as a normal backspace

Details

Related Issues

Fixes #25867 #25856 #25907 #25926 #25934

How to Validate

Pre-Merge Checklist

  • Updated relevant documentation and README (if needed)
  • Added/updated tests (if needed)
  • Noted breaking changes (if any)
  • Validated on required platforms/methods:
    • MacOS
      • npm run
      • npx
      • Docker
      • Podman
      • Seatbelt
    • Windows
      • npm run
      • npx
      • Docker
    • Linux
      • npm run
      • npx
      • Docker

@dogukanozen dogukanozen requested a review from a team as a code owner April 23, 2026 20:24
@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request addresses a regression in keypress handling on Windows environments. Previously, the logic for detecting Ctrl+Backspace was too broad, causing standard backspace inputs in legacy Windows terminals like cmd.exe and PowerShell to be incorrectly interpreted as word-deletion commands. The changes refine this detection to target only Windows Terminal sessions, restoring expected behavior for other terminal emulators.

Highlights

  • Refined Ctrl+Backspace Detection: Restricted the detection of Ctrl+Backspace to only occur when the WT_SESSION environment variable is present, ensuring compatibility with Windows Terminal.
  • Regression Fix: Prevented incorrect word deletion in cmd.exe and PowerShell by ensuring plain backspace inputs are no longer misidentified as Ctrl+Backspace.
  • Updated Test Suite: Modified the KeypressContext test to verify that backspace is not treated as a control key when running on Windows without an active Windows Terminal session.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request refines the handling of the backspace character (\b) in Windows environments within the KeypressContext. It restricts the automatic assignment of the ctrl modifier to cases where the WT_SESSION environment variable is present, ensuring that plain backspace inputs in cmd.exe and PowerShell are not incorrectly interpreted as Ctrl+Backspace. Corresponding unit tests have been updated to verify this new behavior. I have no feedback to provide.

The previous fix (google-gemini#21447) treated OS=Windows_NT as sufficient to mark
\b as Ctrl+Backspace, but cmd.exe and PowerShell also send \b for plain
backspace, causing every backspace to delete a whole word on those terminals.

Scope the ctrl=true path to WT_SESSION only (Windows Terminal), which is
the terminal that actually sends \b for Ctrl+Backspace and \x7f for plain
backspace. Update the corresponding test expectation.

Fixes google-gemini#25867
@dogukanozen dogukanozen force-pushed the fix/backspace-word-delete-non-wt-windows branch from 2ac920b to 49eb0fd Compare April 23, 2026 21:15
@dogukanozen
Copy link
Copy Markdown
Contributor Author

/gemini review

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates the KeypressContext to change how the backspace character (\b) is handled. Specifically, it removes the logic that previously marked \b as a control key on Windows systems or within Windows Terminal sessions. The unit tests in KeypressContext.test.tsx have been updated to verify that \b is no longer treated as a control character in these environments. I have no feedback to provide.

@dogukanozen
Copy link
Copy Markdown
Contributor Author

closing this as it’s resolved by #25941

@dogukanozen dogukanozen deleted the fix/backspace-word-delete-non-wt-windows branch April 24, 2026 20:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Backspace deletes word instead of character on Windows

1 participant