Skip to content

Columns seem to ignore lipgloss padding #130

Open
@misterikkit

Description

@misterikkit

I want to pad my cell data with a space on both the left and the right. This is because in many terminals, double-clicking on the text of a cell will select the contents plus the column separator. The common behavior is to delimit only on whitespace. What I want is to quickly copy a cell's contents into my OS clipboard for pasting into other tools.

I tried this by adding a column style that uses .Padding(0, 1) as well as manually adding spaces to the row data, but either way the table seems to trim space before rendering. Any hints on how I should be doing this?

I skimmed through the code and did not find any explicit logic to remove leading or trailing space.

Note: For overflow, I don't care if the ellipsis touches the column separator, because a truncated value is not worth copying into a clipboard.

I am using Version: v0.15.0

Sample Program:

package main

import (
	"fmt"

	"github.com/charmbracelet/lipgloss"
	"github.com/evertras/bubble-table/table"
)

func main() {

	cols := []table.Column{
		table.NewColumn("a", "A", 10).
			WithStyle(
				lipgloss.NewStyle().Padding(0, 1),
			),
	}

	rows := []table.Row{
		table.NewRow(table.RowData{"a": "hello"}),
		table.NewRow(table.RowData{"a": "very long text"}),
	}

	t := table.New(cols).WithRows(rows)
	fmt.Println(t.View())
}

Expected Output:

┏━━━━━━━━━━┓
┃        A ┃
┣━━━━━━━━━━┫
┃    hello ┃
┃ very lo… ┃
┗━━━━━━━━━━┛

Actual Output:

┏━━━━━━━━━━┓
┃         A┃
┣━━━━━━━━━━┫
┃     hello┃
┃very long…┃
┗━━━━━━━━━━┛

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions