BUG [Help Model]: Configured width is not respected in edge-case
Describe the bug
The Help model has a configurable width parameter.
The configured width is applied when calling the ShortHelpView or FullHelpView methods on Help.
Outside of the herein described edge-case, the len of the returned string will be equal to or less than the configured width. However, for both methods, there is an edge-case, resulting in the full string being returned untruncated, with a len that exceeds the configured width.
This occurs when the leading subset of distinct help items (items in ShortHelpView and columns in FullHelpview), fit within the configured width with a margin of 0-2 (and width > 0). In this case, the shouldAddItem helper function will not prevent the addition of new items, instead allowing each item to be added to the final string, exceeding the configured width. The margin mentioned assumes the configured Help.Ellipsis to be of len==1: the edge-case margin is equal to [0 - len(Help.Ellipsis) + 1].
This might duplicate another bug that was reported some time ago.
I have prepared a PR that fixes the issue and describes more technical detail.
Setup
- OS: arch Linux x86_64 (kernel 7.1.8-arch1-3)
- Shell: fish 4.8.1
- Terminal Emulator: ghostty 1.3.1-arch2
- Terminal Multiplexer: tmux 3.7c
- Locale: en_GB.UTF-8
To Reproduce
Steps to reproduce the behavior:
- Clone to my fork with fix
- Copy
./help/testdata/*&./help/help_test.gointo original source-code - Execute tests and observe edge-case failure
Source Code
See the Help model src
Expected behavior
When width is configured, one would ideally be able to expect that it is respected in subsequent model method outputs.
Screenshots
SHORT HELP VIEW
BUG
FIX
FULL HELP VIEW
BUG
FIX
Source: charmbracelet/bubbles