XGameUI: maxTextLength=0 is a limit of 1024 characters (#248) #306

Closed
github-bot wants to merge 1 commit from gh-pr/306/head into gh-pr/306/base
Owner

@⁠carlos-seiffert on GitHub · 2026-11-24 23:27 UTC · original
carlos-seiffert:fix/xgameui-text-limit-default → main · +49 −4 · 1 files · 1 commits · closed without merging

Fixes #248.

Summary

  • In crates/victory-hle/src/modules/xgameui.rs, text_entry_async now turns a maxTextLength of 0 into the documented 1024 characters (GDK reference) once, at entry.
  • That one effective limit goes to both the host dialog (EM_LIMITTEXT, which previously got 0, the edit control's own near-unlimited default) and the trimming of the result.
  • A positive limit is kept as given. limit no longer has a "0 means no limit" case.

Tests

  • New zero_length_limit_is_1024_characters: the test dialog answers 1030 characters with a limit of 0, and 1024 characters plus the NUL come back. Without the change it fails (left: 1, right: 1025).
  • cargo test -p victory-hle: 96 passed, 0 failed (Windows 11, Rust 1.98.1, MSVC).
  • cargo clippy -p victory-hle --all-targets: nothing in this file.
  • The live dialog was not exercised.

Only the new lines follow rustfmt.toml's 100 columns. The rest of the file was already wider, and I left it as is to keep the diff small.

🤖 Generated with Claude Code

**@⁠carlos-seiffert** on GitHub · 2026-11-24 23:27 UTC · [original](https://github.com/fxceless/victory-fork/pull/306) `carlos-seiffert:fix/xgameui-text-limit-default` → `main` · +49 −4 · 1 files · 1 commits · closed without merging Fixes #248. ### Summary - In `crates/victory-hle/src/modules/xgameui.rs`, `text_entry_async` now turns a `maxTextLength` of 0 into the documented 1024 characters ([GDK reference](https://learn.microsoft.com/en-us/gaming/gdk/docs/reference/system/xgameui/functions/xgameuishowtextentryasync)) once, at entry. - That one effective limit goes to both the host dialog (`EM_LIMITTEXT`, which previously got 0, the edit control's own near-unlimited default) and the trimming of the result. - A positive limit is kept as given. `limit` no longer has a "0 means no limit" case. ### Tests - New `zero_length_limit_is_1024_characters`: the test dialog answers 1030 characters with a limit of 0, and 1024 characters plus the NUL come back. Without the change it fails (`left: 1, right: 1025`). - `cargo test -p victory-hle`: 96 passed, 0 failed (Windows 11, Rust 1.98.1, MSVC). - `cargo clippy -p victory-hle --all-targets`: nothing in this file. - The live dialog was not exercised. Only the new lines follow `rustfmt.toml`'s 100 columns. The rest of the file was already wider, and I left it as is to keep the diff small. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
The GDK documents a maxTextLength of 0 as 1024 characters, but the text
entry treated it as no limit: the edit control got 0 (its own default,
about 2^31) and the result was returned whole. The limit is now made
effective once at entry and passed to both the dialog and the trimming of
the result; a positive limit is kept as given.

A test feeds a 1030-character answer with a limit of 0 and checks that
1024 characters (and the NUL) come back; it fails without the change.

Fixes #248.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 03:40:24 +00:00
github-bot closed this pull request 2026-11-26 03:40:24 +00:00
Author
Owner

@⁠carlos-seiffert on GitHub · 2026-11-24 23:30 UTC · original

Closing as a duplicate of #291, which was opened a few minutes earlier with the same fix (0 → 1024 at entry, one limit for the dialog and the result) and an equivalent test. Sorry for the noise.

**@⁠carlos-seiffert** on GitHub · 2026-11-24 23:30 UTC · [original](https://github.com/fxceless/victory-fork/pull/306#issuecomment-7147482432) Closing as a duplicate of #291, which was opened a few minutes earlier with the same fix (0 → 1024 at entry, one limit for the dialog and the result) and an equivalent test. Sorry for the noise.

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No description provided.