[PR #6566] [MERGED] A text field draws its value as typed, § codes included #6952

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

📋 Pull Request Information

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

Base: main ← Head: fix/text-field-value


📝 Commits (2)

  • d02c07c A text field draws its value as typed, § codes included
  • 0cfd1d8 Chat screen cases: long values with codes, scrolled and selected

📊 Changes

3 files changed (+75 additions, -3 deletions)

View changed files

📝 crates/horizon-client-render/src/font.rs (+10 -0)
📝 crates/horizon-client-render/src/screen_draw.rs (+23 -3)
📝 tools/test_chat_screen_parity.py (+42 -0)

📄 Description

Vanilla's EditBox draws its value as a literal component (Component.literal(...) → FormattedCharSequence.forward → StringDecomposer.iterate, not iterateFormatted), so a § in the value is a glyph, the text after it keeps the field's own colour, and the text after the cursor starts at the width of the glyphs before it - which is why a command block's editor shows /say §chello with the code visible.

Horizon drew the field's value through Text::resolve_legacy, so the §c disappeared, hello was recoloured red, and the cursor and the text after it sat 10 px left of where vanilla puts them; the value now goes to the draw unchanged and the cursor advances by the width of the glyphs actually drawn.

Proven: on the build VM, cd ~/.wt/chat4 && python3 tools/parity.py chat_screen → PASS chat_screen, 3035/3035 chat screens match; 0 oracle errors (38 fixed cases: values holding §z, /say §chello, /tellraw @a {"text":"§lbold"}, §, a 200-character value with two codes scrolled to its end and selected, a 300-character paste, the characters a box filters and a 300-character history entry). Before the change the same harness reported 3027/3029 chat screens match with call 1: vanilla {"runs": [["§zabcdefg…"]], "x": 4} against call 1: horizon {"runs": [["abcdefg…"]], "x": 4}, and z drawn at 10 px by vanilla and 4 px by Horizon.

Not proven: the same command in the game's own command block editor or in a chat draft restored from options.txt (no headless case drives those screens); other screen text still resolves legacy codes when it is drawn, which these cases do not cover.


🔄 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/6566 **Author:** [@MSedgeMC](https://github.com/MSedgeMC) **Created:** 11/1/2026 **Status:** ✅ Merged **Merged:** 11/2/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `fix/text-field-value` --- ### 📝 Commits (2) - [`d02c07c`](https://github.com/horizon-rust/horizon/commit/d02c07cde6dca7ffbfd1281d3a09119130cb75e6) A text field draws its value as typed, § codes included - [`0cfd1d8`](https://github.com/horizon-rust/horizon/commit/0cfd1d821ccfd9f44a51bc1640f4045d16af0a4b) Chat screen cases: long values with codes, scrolled and selected ### 📊 Changes **3 files changed** (+75 additions, -3 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client-render/src/font.rs` (+10 -0) 📝 `crates/horizon-client-render/src/screen_draw.rs` (+23 -3) 📝 `tools/test_chat_screen_parity.py` (+42 -0) </details> ### 📄 Description Vanilla's `EditBox` draws its value as a literal component (`Component.literal(...)` → `FormattedCharSequence.forward` → `StringDecomposer.iterate`, not `iterateFormatted`), so a `§` in the value is a glyph, the text after it keeps the field's own colour, and the text after the cursor starts at the width of the glyphs before it - which is why a command block's editor shows `/say §chello` with the code visible. Horizon drew the field's value through `Text::resolve_legacy`, so the `§c` disappeared, `hello` was recoloured red, and the cursor and the text after it sat 10 px left of where vanilla puts them; the value now goes to the draw unchanged and the cursor advances by the width of the glyphs actually drawn. **Proven:** on the build VM, `cd ~/.wt/chat4 && python3 tools/parity.py chat_screen` → `PASS chat_screen`, `3035/3035 chat screens match; 0 oracle errors` (38 fixed cases: values holding `§z`, `/say §chello`, `/tellraw @a {"text":"§lbold"}`, `§`, a 200-character value with two codes scrolled to its end and selected, a 300-character paste, the characters a box filters and a 300-character history entry). Before the change the same harness reported `3027/3029 chat screens match` with `call 1: vanilla {"runs": [["§zabcdefg…"]], "x": 4}` against `call 1: horizon {"runs": [["abcdefg…"]], "x": 4}`, and `z` drawn at 10 px by vanilla and 4 px by Horizon. **Not proven:** the same command in the game's own command block editor or in a chat draft restored from `options.txt` (no headless case drives those screens); other screen text still resolves legacy codes when it is drawn, which these cases do not cover. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 06:30:06 +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#6952
No description provided.