Skip to content

fix(desktop-gpui): Ctrl editing shortcuts in text fields on Windows and Linux - #2773

Merged
richiemcilroy merged 1 commit into
mainfrom
fix/gpui-text-input-ctrl-chords
Oct 22, 2026
Merged

richiemcilroy merged 1 commit into
mainfrom
fix/gpui-text-input-ctrl-chords

Conversation

@richiemcilroy

@richiemcilroy richiemcilroy commented Oct 20, 2026 •

Copy link
Copy Markdown
Member

What

Text fields in the GPUI desktop app now respond to the standard Ctrl editing shortcuts on Windows and Linux: Ctrl+A, Ctrl+C, Ctrl+X, Ctrl+V, Ctrl+Z, Ctrl+Shift+Z, Ctrl+Y, Ctrl+Left/Right (word motion), Ctrl+Shift+Left/Right (word selection), Ctrl+Backspace/Delete (word delete), Ctrl+Home/End (start/end of the field) and Ctrl+Shift+Home/End (select to start/end).

Why

Every chord in the TextInput key context is spelled cmd-*. In our gpui fork cmd parses to the platform modifier, which is the Windows key on Windows and Super on Linux (gpui/src/platform/keystroke.rs, Keystroke::parse). So on those platforms Ctrl+C, Ctrl+V and the rest did nothing inside a field, and Win+C / Super+C were the bound chords instead, which the OS usually takes first.

How

  • text_input::bind_keys now registers text_input::bindings(), a plain function returning the Vec<KeyBinding>, so the keymap can be unit tested without an App.
  • The existing 40 bindings are unchanged and still registered on every platform.
  • On Windows and Linux (cfg!(not(target_os = "macos"))) 17 extra ctrl-* bindings are appended, all scoped to the same TextInput context and mapped to the existing actions. No new actions, no handler changes.

Behaviour per platform

  • macOS: identical keymap. The ctrl bindings are not registered, so every keystroke behaves exactly as before. A golden test pins the 40 macOS bindings and asserts the total stays 40.
  • Windows / Linux: the ctrl chords above work while a text field has focus. Because the bindings are scoped to TextInput, they only match while a field is focused; outside a field the keystrokes reach the same handlers as today. The editor's own Ctrl+Z project undo and other window handlers already return early while a field has focus (text_input_has_focus), so nothing that previously handled these chords inside a field is shadowed.

Mouse users are unaffected: no rendering, layout or pointer code changed.

Tests

New unit tests in ui/text_input.rs (run by the existing cargo test jobs on all three OSes):

  • every binding is a single keystroke in the TextInput context
  • no keystroke is bound twice
  • no bare printable key is bound (which would stop it being typed)
  • macOS golden list: all 40 existing chords map to the same actions, and on macOS the total is exactly 40
  • the 17 ctrl chords map to the expected actions on Windows/Linux and are absent on macOS

Manual checklist

  • Windows 11: in the settings and editor text fields, Ctrl+A/C/X/V/Z/Y and Ctrl+Shift+Z work; Ctrl+Left/Right moves by word; Ctrl+Backspace deletes a word; Ctrl+Home/End jump to the ends
  • Windows 11: with no field focused, editor Ctrl+Z still undoes the project edit
  • Ubuntu (X11 and Wayland): same checks as Windows
  • Windows/Linux IME (for example Japanese or Pinyin) composition still works in a field
  • macOS: text field shortcuts unchanged (Cmd+C/V/Z, Option+arrows, Ctrl+Cmd+Space)

RetriggerView in GreptileConfidence Score: 5/5

The PR appears safe to merge; no actionable issues were found.

Summary

Adds 17 Ctrl editing shortcuts for Windows and Linux without changing the macOS keymap.

  • Windows and Linux text fields now respond to standard Ctrl editing shortcuts.

Reviews (1) · Last reviewed commit: "fix(desktop-gpui): Ctrl editing shortcut..." · Reviewed by Greptile

@vercel

vercel Bot commented Oct 20, 2026

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
cap-status Ready Ready Preview Oct 20, 2026 8:42pm UTC

@blacksmith-sh

This comment has been minimized.

@richiemcilroy

Copy link
Copy Markdown
Member Author

@greptileai review

@blacksmith-sh

This comment has been minimized.

@blacksmith-sh

This comment has been minimized.

@richiemcilroy
richiemcilroy marked this pull request as ready for review October 22, 2026 06:21
@richiemcilroy

Copy link
Copy Markdown
Member Author

@greptileai review

@capy-ai capy-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Capy found no issues.

View 1 other finding in Capy.

Open in Capy

@blacksmith-sh

blacksmith-sh Bot commented Oct 22, 2026

Copy link
Copy Markdown

Found 2 test failures on Blacksmith runners:

Failures

Test View Logs
crash/recorder-kill/inproc/static-screen/static-screen View Logs
crash/recorder-kill/oop/static-screen/static-screen View Logs

Fix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need.

This branch was successfully deployed

2 active deployments
Preview – cap-web — 03193095 Deployed Oct 20, 2026 by vercel[bot]
Preview – cap-status — 03193095 Deployed Oct 20, 2026 by vercel[bot]
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.

1 participant