Skip to content

fix(table): Use ansi.Truncate instead of runewidth.Truncate#883

Open
jedevc wants to merge 1 commit intocharmbracelet:masterfrom
jedevc:fix-table-truncate
Open

fix(table): Use ansi.Truncate instead of runewidth.Truncate#883
jedevc wants to merge 1 commit intocharmbracelet:masterfrom
jedevc:fix-table-truncate

Conversation

@jedevc
Copy link

@jedevc jedevc commented Feb 12, 2026

runewidth.Truncate does not consider terminal escape characters - this means that if a table cell contains funky characters, then it will be incorrectly truncated.

  • I have read CONTRIBUTING.md.
  • I have created a discussion that was approved by a maintainer (for new features).

Minimal reproducer:

package main

import (
	"fmt"

	"github.com/charmbracelet/bubbles/table"
	"github.com/charmbracelet/lipgloss"
)

func main() {
	cols := []table.Column{{Title: "Name", Width: 7}}
	value := lipgloss.NewStyle().Foreground(lipgloss.Color("1")).Render("ABCDEFGH")
	rows := []table.Row{{value}}

	t := table.New(
		table.WithColumns(cols),
		table.WithRows(rows),
	)

	fmt.Println(t.View())
}

Before:

image

After:

image

runewidth.Truncate does not consider terminal escape characters - this
means that if a table cell contains funky characters, then it will be
incorrectly truncated.

Signed-off-by: Justin Chadwell <me@jedevc.com>
@jedevc jedevc requested a review from aymanbagabas as a code owner February 12, 2026 15:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant