Skip to content

Fix input loss with Unicode initial text - #302

Merged
djc merged 1 commit into
console-rs:mainfrom
rksharma-owg:codex/fix-console-unicode-prefix
Oct 17, 2026
Merged

djc merged 1 commit into
console-rs:mainfrom
rksharma-owg:codex/fix-console-unicode-prefix

Conversation

@rksharma-owg

Copy link
Copy Markdown
Contributor

read_line_initial_text counts the initial text in UTF-8 bytes but stores input as Vec<char>. With a λ prefix, typing abc returns bc; longer multibyte prefixes can discard the entire response. The same mismatch affects the Backspace boundary.

Use the length of the collected character buffer for both operations, preserving the existing read-only prefix behavior.

Add a Linux/macOS pseudo-terminal regression test that exercises the public method with ASCII, Greek, emoji, CJK and combining prefixes, Unicode typed input, an empty prefix, and Backspace at the prefix boundary. The test fails on the original code (bc versus abc) and passes with this fix. It uses the existing libc dependency.

Validation:

  • Local Rust 1.99.0/macOS: make check, all seven make test configurations, make lint, make format-check, and make doc passed.
  • Fork cloud CI: 20/20 jobs passed for 27442a22ec39bc280a77d814c5a678b24610ba6b, covering the upstream workflow matrix: MSRV 1.71, Windows/macOS/Linux, WASM/WASI, beta/nightly, Clippy, rustfmt and minimal versions. The untouched target commit also passed 20/20 jobs. The interactive regression runs on Linux/macOS; other targets retain their existing checks.

Fixes #301.

@djc djc left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks!

@djc
djc merged commit 219c841 into console-rs:main Oct 17, 2026
20 checks passed
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.

Non-ASCII initial text causes read_line_initial_text to lose typed input

2 participants