Skip to content

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

Closed
dogukanozen wants to merge 1 commit into
google-gemini:mainfrom
dogukanozen:fix/backspace-word-delete-non-wt-windows
Closed

fix(cli): restrict ctrl+backspace detection to Windows Terminal only#25881
dogukanozen wants to merge 1 commit into
google-gemini:mainfrom
dogukanozen:fix/backspace-word-delete-non-wt-windows

Conversation

@dogukanozen

@dogukanozen dogukanozen commented Apr 23, 2026

Copy link
Copy Markdown
Contributor

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
  • cmd.exe and PowerShell send \b (0x08) for plain backspace, not \x7f — so they were incorrectly being treated as Ctrl+Backspace, deleting a whole word on every backspace press
  • Fixed by scoping ctrl=true to WT_SESSION only (Windows Terminal), which is the only terminal that sends \b for Ctrl+Backspace and \x7f for plain backspace
  • Updated the test that expected OS=Windows_NT alone to set ctrl=true

Fixes #25867

Test plan

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

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@dogukanozen
dogukanozen requested a review from a team as a code owner April 23, 2026 20:22
@google-cla

google-cla Bot commented Apr 23, 2026

Copy link
Copy Markdown

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@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 input handling for Windows users. By narrowing the scope of Ctrl+Backspace detection to specifically target Windows Terminal sessions, the change ensures that standard terminal emulators like cmd.exe and PowerShell maintain correct backspace behavior, preventing accidental word deletion.

Highlights

  • Refined Ctrl+Backspace Detection: Restricted the detection of Ctrl+Backspace to only occur when the Windows Terminal environment variable (WT_SESSION) is present.
  • Regression Fix: Prevented standard backspace keys in cmd.exe and PowerShell from being incorrectly interpreted as Ctrl+Backspace, which previously caused unintended word deletions.
  • Test Suite Update: Updated the KeypressContext test suite 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.

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

Copy link
Copy Markdown
Contributor

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. The logic now specifically checks for the WT_SESSION environment variable to identify Windows Terminal, ensuring that \b is only treated as Ctrl+Backspace in that context, while standard consoles like cmd.exe and PowerShell treat it as a regular backspace. The associated test case has been updated to verify this behavior. I have no feedback to provide.

@sripasg sripasg added the size/s A small PR label Jun 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/s A small PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Backspace deletes word instead of character on Windows

2 participants