[PR #6507] [MERGED] Chat: Ctrl and Shift read the live modifiers, so Ctrl+Shift+arrows select by word #6923

Closed
opened 2026-11-03 06:29:18 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/6507
Author: @anweisen
Created: 11/1/2026
Status: ✅ Merged
Merged: 11/1/2026
Merged by: @ludovic111

Base: main ← Head: fix/chat-word-selection


📝 Commits (1)

  • 1e5c904 Chat: Ctrl and Shift read the live modifiers, so Ctrl+Shift+arrows select by word

📊 Changes

1 file changed (+5 additions, -9 deletions)

View changed files

📝 crates/horizon-client/src/game/chat.rs (+5 -9)

📄 Description

🤖 Opened by anweisen's AI agent (Claude Code, Opus 5.5), not by anweisen personally.

What and why

Fixes #6492

In the chat box, Ctrl+Shift+Left/Right should select a word at a time, like in vanilla. In Horizon it doesn't.

TextField::key already handles this correctly when it gets the right ctrl and shift flags. The chat just wasn't passing them. chat_key_code checked self.keys for the modifier keys, but every ModifiersChanged event calls sync_toggle(SNEAK) and sync_toggle(SPRINT). While a screen is open neither toggle is down, so those calls remove ShiftLeft and ControlLeft from self.keys again. By the time the arrow key arrives, both flags are false. (The right-hand Shift and Ctrl aren't touched, which is why this is easy to miss.)

#6153 fixed the same problem in the command block, block editor and debug options screens. It assumed the chat already read the live modifiers, but it still used self.keys.

The change is in game/chat.rs: ctrl now comes from has_control_down_with_quirk() (Cmd on macOS, Ctrl elsewhere) and shift from has_shift_down(), the same live state the dialogs and the screens from #6153 use. Ctrl+Left/Right word jumps, Shift+arrow selection and Ctrl+Backspace/Delete in chat read the same flags, so they work with the left-hand keys again too.

Kind

  • parity: Horizon now does what vanilla 26.3 does
  • bug: a crash or a breakage
  • perf: faster, or less memory
  • feature: something new for players (listed under New in the release notes)
  • extra: Horizon-only, off by default
  • tooling: tools, CI, tests, harnesses
  • docs

Vanilla reference

ChatScreen.keyPressed passes the key to EditBox.keyPressed, which reads KeyEvent.hasShiftDown() and hasControlDownWithQuirk() (InputWithModifiers) from the event's own modifier bits. Vanilla doesn't keep a key cache here, so the live modifiers are what match it. No harness covers chat key handling.

Other projects' code

none

Self-check

pr_ready (tools/pr_ready.py --quick on 872cf4cd330f, against origin/main at dd289c890, 3 min 25 s)

Check Result
Scope ✅ 1 files, +5 −9
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ✅ 594 passed (26 s)
rustfmt ✅ (5 s)
clippy ✅ (1 min 41 s)
tests: horizon-client ✅ 590 passed (1 min 12 s)
doc tests ✅ 0 passed (1 s)
content root tests ➖ content root untouched
tokens.css up to date ➖ theme untouched
launcher rustfmt ➖ launcher untouched
launcher clippy ➖ launcher untouched
launcher tests ➖ launcher untouched
Parity ➖ not run (--quick): CI's parity job picks the affected harnesses
Label player-facing: feature if players get something new, no label for a fix (release-now if urgent)

Not tried with a real keyboard. There's no test harness that can build a Game and send it window events, so nothing new is unit-tested; the word movement itself is TextField::key, which was already correct.

🤖 Generated with Claude Code


🔄 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/horizon-rust/horizon/pull/6507 **Author:** [@anweisen](https://github.com/anweisen) **Created:** 11/1/2026 **Status:** ✅ Merged **Merged:** 11/1/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `fix/chat-word-selection` --- ### 📝 Commits (1) - [`1e5c904`](https://github.com/horizon-rust/horizon/commit/1e5c904d184495558505fdbe2429fc2fedd28a9c) Chat: Ctrl and Shift read the live modifiers, so Ctrl+Shift+arrows select by word ### 📊 Changes **1 file changed** (+5 additions, -9 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game/chat.rs` (+5 -9) </details> ### 📄 Description > 🤖 Opened by anweisen's AI agent (Claude Code, Opus 5.5), not by anweisen personally. ## What and why Fixes #6492 In the chat box, Ctrl+Shift+Left/Right should select a word at a time, like in vanilla. In Horizon it doesn't. `TextField::key` already handles this correctly when it gets the right `ctrl` and `shift` flags. The chat just wasn't passing them. `chat_key_code` checked `self.keys` for the modifier keys, but every `ModifiersChanged` event calls `sync_toggle(SNEAK)` and `sync_toggle(SPRINT)`. While a screen is open neither toggle is down, so those calls remove `ShiftLeft` and `ControlLeft` from `self.keys` again. By the time the arrow key arrives, both flags are false. (The right-hand Shift and Ctrl aren't touched, which is why this is easy to miss.) #6153 fixed the same problem in the command block, block editor and debug options screens. It assumed the chat already read the live modifiers, but it still used `self.keys`. The change is in `game/chat.rs`: `ctrl` now comes from `has_control_down_with_quirk()` (Cmd on macOS, Ctrl elsewhere) and `shift` from `has_shift_down()`, the same live state the dialogs and the screens from #6153 use. Ctrl+Left/Right word jumps, Shift+arrow selection and Ctrl+Backspace/Delete in chat read the same flags, so they work with the left-hand keys again too. ## Kind - [x] parity: Horizon now does what vanilla 26.3 does - [x] bug: a crash or a breakage - [ ] perf: faster, or less memory - [ ] feature: something new for players (listed under New in the release notes) - [ ] extra: Horizon-only, off by default - [ ] tooling: tools, CI, tests, harnesses - [ ] docs ## Vanilla reference `ChatScreen.keyPressed` passes the key to `EditBox.keyPressed`, which reads `KeyEvent.hasShiftDown()` and `hasControlDownWithQuirk()` (`InputWithModifiers`) from the event's own modifier bits. Vanilla doesn't keep a key cache here, so the live modifiers are what match it. No harness covers chat key handling. ## Other projects' code none ## Self-check **pr_ready** (`tools/pr_ready.py --quick` on 872cf4cd330f, against origin/main at dd289c890, 3 min 25 s) | Check | Result | | --- | --- | | Scope | ✅ 1 files, +5 −9 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ✅ 594 passed (26 s) | | rustfmt | ✅ (5 s) | | clippy | ✅ (1 min 41 s) | | tests: horizon-client | ✅ 590 passed (1 min 12 s) | | doc tests | ✅ 0 passed (1 s) | | content root tests | ➖ content root untouched | | tokens.css up to date | ➖ theme untouched | | launcher rustfmt | ➖ launcher untouched | | launcher clippy | ➖ launcher untouched | | launcher tests | ➖ launcher untouched | | Parity | ➖ not run (--quick): CI's parity job picks the affected harnesses | | Label | player-facing: `feature` if players get something new, no label for a fix (`release-now` if urgent) | Not tried with a real keyboard. There's no test harness that can build a `Game` and send it window events, so nothing new is unit-tested; the word movement itself is `TextField::key`, which was already correct. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 06:29:18 +07: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
horizon-rust/horizon#6923
No description provided.