[PR #7771] The command reader skips the whitespace Java does #7810

Open
opened 2026-11-03 07:24:29 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/7771
Author: @razzo715
Created: 11/2/2026
Status: 🔄 Open

Base: main ← Head: fix/command-java-whitespace


📝 Commits (1)

  • eac1265 The command reader skips the whitespace Java does (#7672)

📊 Changes

2 files changed (+53 additions, -1 deletions)

View changed files

📝 crates/horizon-command/src/lib.rs (+15 -1)
📝 crates/horizon-command/src/tests.rs (+38 -0)

📄 Description

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

What and why

Reader::skip_whitespace skipped what Rust's char::is_whitespace calls whitespace, while Brigadier's StringReader.skipWhitespace uses Java's Character.isWhitespace (#7672). The two differ on eight characters:

  • Rust skips U+0085 and the no-break spaces U+00A0, U+2007 and U+202F; Java doesn't, so @e[ type=minecraft:pig] with a no-break space parsed in Horizon and fails in vanilla.
  • Java skips U+001C to U+001F; Rust doesn't, so a selector with U+001F between its options failed in Horizon and parses in vanilla.

Reader::is_java_whitespace is Java's set, and skip_whitespace uses it.

Fixes #7672

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

Brigadier StringReader.skipWhitespace: while (canRead() && Character.isWhitespace(peek())) skip();. The set is Java 25's Character.isWhitespace over every code point (the game's Java), listed by running it: U+0009–U+000D, U+001C–U+0020, U+1680, U+2000–U+2006, U+2008–U+200A, U+2028, U+2029, U+205F, U+3000.

New test: tests::whitespace_is_what_java_character_is_whitespace_says compares is_java_whitespace with that list over all of Unicode, checks the reader skips U+001F and U+3000 and stops at U+00A0, U+2007, U+202F and U+0085, and checks a selector with U+001F parses and one with U+00A0 doesn't. With the old char::is_whitespace it fails.

Other projects' code

none

Self-check

pr_ready (tools/pr_ready.py --quick --base upstream/main on DESKTOP-Q5U547F, against upstream/main at 68ff46998, 3 min 52 s)

Check Result
Scope ✅ 3 files, +54 −1
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ✅ 614 passed (2 min 1 s)
rustfmt ✅ (17 s)
Rust ⚠️ 1.98.1 is older than CI's stable (1.99): clippy may flag lints CI doesn't, update with rustup update
clippy ✅ (1 min 20 s)
tests: horizon-command ✅ 30 passed (2 s)
doc tests ✅ 0 passed (3 s)
content root tests ➖ content root untouched
mod API up to date ➖ native hooks untouched
tokens.css up to date ➖ theme untouched
launcher rustfmt ➖ launcher untouched
launcher clippy ➖ launcher untouched
launcher tests ➖ launcher untouched
Parity ➖ 344 affected, to run in CI (--quick): block_pile, block_properties, block_support, block_survival, block_tint, block_transformer, block_update, blocking_item_damage, blocking_rules, blockstate_binding, blockstate_model, blockstate_transform and 332 more
Label player-facing: feature if players get something new, no label for a fix (release-now if urgent)

The scope counts an untracked file the game wrote in the checkout (horizon_official_server.txt); the change itself is 2 files. The parity harnesses are left to CI (command_parse among them): a full local run ran out of disk on this machine.

🤖 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/7771 **Author:** [@razzo715](https://github.com/razzo715) **Created:** 11/2/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `fix/command-java-whitespace` --- ### 📝 Commits (1) - [`eac1265`](https://github.com/horizon-rust/horizon/commit/eac12655bc9cea8f0efa35480f2d7f3da3840f4a) The command reader skips the whitespace Java does (#7672) ### 📊 Changes **2 files changed** (+53 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-command/src/lib.rs` (+15 -1) 📝 `crates/horizon-command/src/tests.rs` (+38 -0) </details> ### 📄 Description > 🤖 Opened by razzo715's AI agent (Claude Code, Claude Opus 5.5), not by razzo715 personally. ## What and why `Reader::skip_whitespace` skipped what Rust's `char::is_whitespace` calls whitespace, while Brigadier's `StringReader.skipWhitespace` uses Java's `Character.isWhitespace` (#7672). The two differ on eight characters: - Rust skips U+0085 and the no-break spaces U+00A0, U+2007 and U+202F; Java doesn't, so `@e[ type=minecraft:pig]` with a no-break space parsed in Horizon and fails in vanilla. - Java skips U+001C to U+001F; Rust doesn't, so a selector with U+001F between its options failed in Horizon and parses in vanilla. `Reader::is_java_whitespace` is Java's set, and `skip_whitespace` uses it. Fixes #7672 ## Kind - [x] 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 Brigadier `StringReader.skipWhitespace`: `while (canRead() && Character.isWhitespace(peek())) skip();`. The set is Java 25's `Character.isWhitespace` over every code point (the game's Java), listed by running it: U+0009–U+000D, U+001C–U+0020, U+1680, U+2000–U+2006, U+2008–U+200A, U+2028, U+2029, U+205F, U+3000. New test: `tests::whitespace_is_what_java_character_is_whitespace_says` compares `is_java_whitespace` with that list over all of Unicode, checks the reader skips U+001F and U+3000 and stops at U+00A0, U+2007, U+202F and U+0085, and checks a selector with U+001F parses and one with U+00A0 doesn't. With the old `char::is_whitespace` it fails. ## Other projects' code none ## Self-check **pr_ready** (`tools/pr_ready.py --quick --base upstream/main` on DESKTOP-Q5U547F, against upstream/main at 68ff46998, 3 min 52 s) | Check | Result | | --- | --- | | Scope | ✅ 3 files, +54 −1 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ✅ 614 passed (2 min 1 s) | | rustfmt | ✅ (17 s) | | Rust | ⚠️ 1.98.1 is older than CI's stable (1.99): clippy may flag lints CI doesn't, update with `rustup update` | | clippy | ✅ (1 min 20 s) | | tests: horizon-command | ✅ 30 passed (2 s) | | doc tests | ✅ 0 passed (3 s) | | content root tests | ➖ content root untouched | | mod API up to date | ➖ native hooks untouched | | tokens.css up to date | ➖ theme untouched | | launcher rustfmt | ➖ launcher untouched | | launcher clippy | ➖ launcher untouched | | launcher tests | ➖ launcher untouched | | Parity | ➖ 344 affected, to run in CI (--quick): block_pile, block_properties, block_support, block_survival, block_tint, block_transformer, block_update, blocking_item_damage, blocking_rules, blockstate_binding, blockstate_model, blockstate_transform and 332 more | | Label | player-facing: `feature` if players get something new, no label for a fix (`release-now` if urgent) | The scope counts an untracked file the game wrote in the checkout (`horizon_official_server.txt`); the change itself is 2 files. The parity harnesses are left to CI (`command_parse` among them): a full local run ran out of disk on this machine. 🤖 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>
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#7810
No description provided.