feat(hm-common): add string utils (ellipsis, align, escape)#174
Merged
Conversation
Port budget-aware, display-width/grapheme-correct string helpers from atuin (crates/atuin-common/src/string/, MIT) into a new hm_common::string module: - ellipsis: EllipsizeExt (ellipsize/pad_ellipsize), Indicator, Pos, Measure - align: AlignExt::pad_to, Alignment - escape: EscapeNonPrintablePosixExt (cat -v control-char escaping) Always compiled here (upstream gates align/ellipsis behind a `unicode` feature). Tests ported and adapted to repo conventions: rstest over bare #[test], std assert_eq in place of pretty_assertions. Adds unicode-width and unicode-segmentation workspace deps. Also point CLAUDE.md's shared-utilities crate at hm-common as the source of truth.
Use the new hm_common::string helpers where the codebase hand-rolled the
same logic, fixing latent width/escaping bugs in the process:
- scheduler: derive a step's display_name via EllipsizeExt instead of
chars().take(39) + "…" — now budgets by display columns and cuts on
grapheme boundaries.
- progress summary: pad the step-name column with AlignExt::pad_to over a
unicode-width budget instead of byte-length {:<n$}, so multibyte/wide
names line up.
- human + progress renderers: escape raw StepLog subprocess output with
EscapeNonPrintablePosixExt before writing it to the terminal, so build
logs can't drive the terminal (cursor moves, screen clears, …).
Adds hm-common dep to hm-exec and unicode-width dep to hm-render.
Regression tests for the escaping and wide-glyph alignment.
markovejnovic
marked this pull request as ready for review
July 26, 2026 02:49
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Generated by an AI agent.