fix(monitor): correct formatIssueShort overhead calculation#53
Merged
Conversation
- scripts/pre-commit.sh: checks gofmt on staged .go files, go vet, go build - make install-hooks: symlinks hook into .git/hooks/pre-commit - README: document make install-hooks in dev section Same pattern as nightshift and sidecar.
The overhead for title width calculation in formatIssueShort was
overestimating by 3 chars:
- Tag was counted as 8 (' [TAG] ' with phantom 2 leading spaces)
but actual category tags are 5 chars plus 1 space = 6 chars
- Type icon was hardcoded as 2 chars wide but all type icons
are 1 visual char; the space-after-icon was already in the
3-spaces count
Correct formula: 4(panel) + 5(tag) + 1(space) + typeIconWidth +
idWidth + priWidth + 3(format spaces)
This gives task titles 3 more characters of display space, reducing
premature truncation in both td monitor and sidecar embedded mode.
Fixes: title truncation visible in sidecar td view vs standalone
td monitor (github.com/marcus/sidecar/issues/215)
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.
Problem
The
formatIssueShortfunction calculates available title width using an overhead that overestimates by 3 chars.Error 1:
8was meant for the row prefix" [TAG] "(8 chars), but the actual format is"%s %s"(tag, issueStr)where tag=[RDY]= 5 chars + 1 space = 6 chars.Error 2: Type icon hardcoded as
2but all icons (■●◆✗○) are 1 visual char.Fix
Gives task titles 3 more display characters before truncation.
Impact
td monitorand sidecar's embedded td view (sidecar#215)lipgloss.Width()for terminal accuracyTests pass:
go test ./pkg/monitor/...