-
Notifications
You must be signed in to change notification settings - Fork 311
Description
Describe the bug
When the width of the content of a table is less than or equal to the maximum allowed width of the table, but the same number incremented by the number of column borders is greater than the maximum allowed width of the table, the table doesn't wrap nor truncate its content.
In short, the table doesn't count the borders when it computes its width.
Setup
Please complete the following information along with version numbers, if applicable.
- OS: Ubuntu
- Shell: Bash
- Terminal Emulator: kitty
- Terminal Multiplexer: N/A
- Locale: en_US.UTF-8
go.mod:
module git.fita.dev/lipgloss-table-width-issue
go 1.24.5
require github.com/charmbracelet/lipgloss v1.1.0
require (
github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect
github.com/charmbracelet/colorprofile v0.2.3-0.20250311203215-f60798e515dc // indirect
github.com/charmbracelet/x/ansi v0.8.0 // indirect
github.com/charmbracelet/x/cellbuf v0.0.13-0.20250311204145-2c3ea96c31dd // indirect
github.com/charmbracelet/x/term v0.2.1 // indirect
github.com/lucasb-eyer/go-colorful v1.2.0 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/mattn/go-runewidth v0.0.16 // indirect
github.com/muesli/termenv v0.16.0 // indirect
github.com/rivo/uniseg v0.4.7 // indirect
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e // indirect
golang.org/x/sys v0.30.0 // indirect
)
To Reproduce
Steps to reproduce the behavior:
Create a table with a single cell and a width of 10, insert a single row with ten characters.
Source Code
package main
import (
"fmt"
"os"
"strconv"
"github.com/charmbracelet/lipgloss/table"
)
func main() {
wrapped, _ := strconv.ParseBool(os.Args[1])
width, _ := strconv.Atoi(os.Args[2])
t := table.New().Wrap(wrapped).Width(width).Row("0123456789")
fmt.Println(t)
}Expected behavior
Cell content should be wrapped/truncated so that the table doesn't exceed its width while still showing its borders.
Additional context
Not required
