Skip to content

Preserve combining marks at string truncation boundaries - #303

Open
jadenfix wants to merge 1 commit into
console-rs:mainfrom
jadenfix:fix/preserve-truncated-combining-marks
Open

jadenfix wants to merge 1 commit into
console-rs:mainfrom
jadenfix:fix/preserve-truncated-combining-marks

Conversation

@jadenfix

Copy link
Copy Markdown

truncate_str("e\u{301}xy", 1, "") currently returns plain e, dropping its combining acute accent. The ANSI-aware path stops as soon as the column budget is reached; the non-ANSI path already keeps following zero-width characters.

Continue until the next character would exceed the budget. Regression cases cover combining marks, multiple marks, CJK, tail budgets, zero width and ANSI resets. The borrowed fast path is unchanged. This retains the existing scalar-width semantics; it does not add grapheme-cluster truncation.

Validation: the regression fails on unmodified main and passes with the fix. All seven make test feature configurations, make check, make doc, Clippy with warnings denied, and formatting pass on macOS. A separate public-API consumer confirms ANSI/non-ANSI output parity and unchanged Cow::Borrowed cases. Other platforms and MSRV remain upstream CI checks.

Prepared with Codex assistance; independently reviewed by a second agent before submission.

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.

1 participant