Skip to content

Commit

Permalink
chore: cleanup + docs
Browse files Browse the repository at this point in the history
  • Loading branch information
Dolev Hadar committed Dec 5, 2024
1 parent 0c66dda commit f989fa1
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
4 changes: 2 additions & 2 deletions tree/renderer.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,8 @@ func (r *renderer) render(node Node, root bool, prefix string) string {
)

// If the line is shorter than the desired width, we pad it with spaces.
if lipgloss.Width(line) < r.width {
line = line + itemStyle.Render(strings.Repeat(" ", r.width-lipgloss.Width(line)))
if pad := r.width - lipgloss.Width(line); pad > 0 {
line = line + itemStyle.Render(strings.Repeat(" ", pad))
}
strs = append(
strs,
Expand Down
3 changes: 3 additions & 0 deletions tree/tree.go
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,9 @@ func (t *Tree) Indenter(indenter Indenter) *Tree {
return t
}

// Width sets the tree width.
//
// Items will be padded to account for the entire width of the tree.
func (t *Tree) Width(width int) *Tree {
t.ensureRenderer().width = width
return t
Expand Down

0 comments on commit f989fa1

Please sign in to comment.