Skip to content

fix(cmd_userinfo): align the +userinfo value column, independent of tab width (#459)#469

Merged
Aybook merged 1 commit into
devfrom
feat/459-userinfo-alignment
Jul 18, 2026
Merged

fix(cmd_userinfo): align the +userinfo value column, independent of tab width (#459)#469
Aybook merged 1 commit into
devfrom
feat/459-userinfo-alignment

Conversation

@Aybook

@Aybook Aybook commented Jul 18, 2026

Copy link
Copy Markdown
Collaborator

Closes #459.

The +userinfo value 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 \t for Sent/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

  • A small align_labels pass 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.
  • Banner/blank lines are untouched; the second %s on Level: %s [ %s ] rides along in the tail.
  • Lang files are not touched - align_labels normalises 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:

Nick: 		[HUBOWNER]Aybo          Nick:       [HUBOWNER]Aybo
Version:  	AirDC++ 4.30            Version:    AirDC++ 4.30
Sent:        	686 B               Sent:       686 B
Received: 	41.68 KB                Received:   41.68 KB

Removing the tab prefix also turns 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).

Tests (§1a.7)

New 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 independently, 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_test unaffected (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 #core is 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

…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>
@Aybook
Aybook merged commit 9dcff20 into dev Jul 18, 2026
9 checks passed
@Aybook
Aybook deleted the feat/459-userinfo-alignment branch July 18, 2026 15:31
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