Bugfix/assignee introducing new line #59
No reviewers
Labels
No labels
bug
ci
documentation
duplicate
enhancement
feature
good first issue
help wanted
invalid
performance
priority
P0
priority
P1
priority
P2
question
refactor
size
L
size
M
size
S
size
XL
size
XS
tests
trivial
wontfix
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
noe.trevino/paso!59
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "bugfix/assignee-introducing-new-line"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@ -0,0 +79,4 @@Foreground(lipgloss.Color(subtleColor)).Render(separator),ellipsis: ellipsisStyle.Background(lipgloss.Color(bg)).Render(ellipsisText),}Hardcoded dependency on
theme.Subtleviolates dependency injection. ThenewSegmentTruncatorfunction already accepts abgparameter but directly imports and usestheme.Subtleinstead of receiving it as a parameter. This couples the truncator to the theme package unnecessarily and makes testing harder.@ -0,0 +15,4 @@// NewStyledSegment creates a Segment with the given text, style, and background color.// The background is applied to the style upfront rather than deferred to each render call.func NewStyledSegment(text string, style lipgloss.Style, bg string) Segment {Closure captures
bgparameter unnecessarily. TheRenderfunction inNewStyledSegmentcreates a closure that captures thebgparameter and applies it on every render. This could lead to bugs if the background changes after segment creation. Consider applying the background to the style upfront instead of deferring it.@ -0,0 +102,4 @@// tryFitWithTruncation walks backwards through segments to find how many complete// segments fit, and whether a partial last segment can be shown.func (t *segmentTruncator) tryFitWithTruncation() string {Complex nested logic in
tryFitWithTruncation. This method mixes two different truncation strategies (partial segment truncation and complete segment truncation) in a single loop with multiple conditions. This violates the Single Responsibility Principle and makes the code hard to follow. Consider extracting into separate methods:tryFitPartialSegment(i)andtryFitCompleteSegments(i).@ -0,0 +1,157 @@package textMissing validation.
newSegmentTruncatordoesn't validate inputs. IfmaxWidthis negative or zero, or ifsegmentsis empty, the behavior is undefined and could lead to out-of-bounds access inprefixWidth. Add guard clauses or document preconditions.@ -171,3 +99,4 @@}// Blocked badgeif task.IsBlocked {DRY violation: repeated pattern in all render functions.
renderTaskSummaryTitle,renderTaskCardLabels, andrenderTaskSummaryMetadataall follow the exact same pattern of creating segments and callingTruncateSegmentswith a leading space prepended. This repetition could be extracted into a helper function likerenderWithLeadingSpace(segments, separator, maxWidth, bg).Long method with sequential append operations. This function has 35 lines with repetitive segment building logic. Each conditional block follows the pattern: check condition, create style, append segment. This is a textbook case for the Builder pattern or Extract Method refactoring. Consider extracting methods:
appendTypeSegment(segments, task),appendPrioritySegment(segments, task), etc.Duplicate style creation logic. Lines 89-92 and 201-204 (in the diff) both create similar "subtle italic" styles for missing data. This is code duplication that violates DRY. Extract to a function or constant style:
MissingDataStyleorcreateSubtleItalicStyle(bg).PR Summary (auto-generated)
• Fixed text wrapping bug in task cards that was causing assignee names and labels to introduce unwanted newlines when rendered
• Refactored task card rendering (internal/tui/components/task.go) to use a new segment-based truncation system with character-level precision instead of word-level truncation
• Created new text/segment_truncator.go package implementing TruncateSegments() function that measures plain text width using runewidth before applying lipgloss styling, eliminating measurement discrepancies
• Added taskCardSafetyBuffer constant (value: 3) to account for leading space and margins, preventing lipgloss word-wrapping edge cases
• Removed unused EllipsisStyle from styles.go as ellipsis rendering is now handled by the truncator
• Added comprehensive test coverage: task_test.go with 13 tests and segment_truncator_test.go with 24 tests validating truncation behavior at various widths, character-level truncation, and Unicode handling
• Updated snapshot tests to reflect corrected rendering (titles now have proper spacing after the leading border character)
@ -0,0 +111,4 @@if truncated != "" {// i >= 1 is guaranteed by the loop bounds, so segments[:i] is// always non-empty and renderJoined always returns content.prefix := t.renderJoined(t.segments[:i])Guard clause inversion opportunity. Lines 115-118 check
if prefix != ""to decide how to format the result. This is a guard pattern that should be flattened: checkif prefix == ""and return early, then handle the normal case without nesting.@ -43,46 +43,13 @@ func RenderTask(task *models.TaskSummary, selected bool, width int) string {}// renderTaskSummaryTitle renders the task title, truncating with "..." if needed.Magic number calculation.
taskCardSafetyBufferis subtracted from width without explanation of why this is correct. The comment in constants.go says "1 + 2" but doesn't explain where those numbers come from or if they match the leading space in renderTaskSummaryTitle (line 48). This could lead to inconsistencies if the rendering logic changes.