fix(cmd_userinfo): align the +userinfo value column, independent of tab width (#459)#469
Merged
Conversation
…ab width (#459) The labels come from the translatable lang file with ragged widths and the code prepended a fixed tab count to each value (\t\t, and a single \t for Sent/Received). Tabs snap to 8-column stops, so the value column landed wherever the label length pushed it, and it also depended on how each client renders a tab - the alignment was never reliable. Fixed in code, independent of tab-stop width: a small align_labels pass pads every value line's label to one width computed from the actual labels (correct in any language, re-derives if a label is retranslated) and lets the value follow directly; the fixed tab prefixes are gone. Space-padding in a monospace chat is the only client-independent alignment. Banner/blank lines are untouched and the second %s on the "Level: %s [ %s ]" line rides along in the tail. Lang files are not touched - align_labels normalises the loaded format string, so there is no per-language space-counting to maintain. Removing the tab prefix also makes two dead `X or msg_unknown` fallbacks (share, slots) live instead of a latent nil-concat crash - strictly more robust, invisible for normal values. cmd_userinfo v0.23 -> v0.24. align_labels is exposed as an `_`-prefixed test seam, so cmd_userinfo joins the seam-only plugins in docs/PLUGIN_API.md §8 (updated four -> five). Provably fails pre-fix (§1a.7): tests/unit/cmd_userinfo_align_test.lua (both smoke.yml legs) drives align_labels against the real msg_userinfo of both shipped lang files and asserts the raw format's value column is ragged (the bug) while the aligned one is uniform, in en and de; a source scan also guards that no fixed tab prefix returns. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
Closes #459.
The
+userinfovalue column was ragged (your testhub screenshot:Nick:/Version:/Sent:landing in different columns). Root cause: the labels come from the translatable lang file with inconsistent widths, and the code prepended a fixed tab count to each value (\t\t, inconsistently a single\tforSent/Received). Tabs snap to 8-column stops, so the value column moved with the label length and with each client's tab-stop width.Fix
align_labelspass pads every value line's label to one width, computed from the actual labels (so it is correct in any language and re-derives automatically if a label is retranslated), and the fixed tab prefixes are removed. Space-padding in a monospace chat is the only client-independent alignment.%sonLevel: %s [ %s ]rides along in the tail.align_labelsnormalises the loaded format string (Lua's[[ ]]already folds CRLF to\n), so there is no per-language space-counting to maintain.Before (v0.23, tabs) vs after (v0.24), rendered:
Removing the tab prefix also turns two dead
X or msg_unknownfallbacks (share,slots) live instead of a latent nil-concat crash - strictly more robust, invisible for normal values.cmd_userinfov0.23 -> v0.24.align_labelsis exposed as an_-prefixed test seam, so cmd_userinfo joins the seam-only plugins indocs/PLUGIN_API.md§8 (updated four -> five).Tests (§1a.7)
New
tests/unit/cmd_userinfo_align_test.lua, both smoke.yml legs. Drivesalign_labelsagainst the realmsg_userinfoof both shipped lang files and asserts the raw format's value column is ragged (the bug) while the aligned one is uniform, inenanddeindependently, plus banner/label/%s-count preservation. A source scan guards that no fixed tab prefix returns (locks the other half of the fix). 20/20 green;plugin_lang_testunaffected (lang files untouched).Review (§1a.6)
Independent reviewer + maintainer spot-check: no blockers, no regressions. Confirmed the alignment invariant holds (all values at column 12), the two regex passes pick the same label boundary, the round-trip is byte-faithful, all 24 tab prefixes removed, and the test is non-vacuous. Both NITs folded in: a source-scan assertion locking the tab-removal, and a comment noting
#coreis a byte width (labels are ASCII by the keep-DC-terms-English convention).Cosmetic only, no functional change. 3.2.x only, not backported.
🤖 Generated with Claude Code