Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vertical AutoMerge keeps unnecessary whitespace when a merged row value is wrapped by WidthMax #261

Open
michaelmdresser opened this issue Feb 28, 2023 · 1 comment
Assignees
Labels
enhancement New feature or request

Comments

@michaelmdresser
Copy link

Describe the bug
When using AutoMerge and WidthMax together on a ColumnConfig, unnecessary whitespace is left in rows where the column value is wrapped and has been merged.

To Reproduce

import (
	"fmt"
	"testing"

	"github.com/jedib0t/go-pretty/v6/table"
	"github.com/jedib0t/go-pretty/v6/text"
)

func TestWrapWithVerticalMerge(t *testing.T) {
	tbl := table.NewWriter()

	tbl.SetColumnConfigs([]table.ColumnConfig{
		{
			Name:             "C1",
			AutoMerge:        true,
			WidthMax:         10,
			WidthMaxEnforcer: text.WrapSoft,
		},
		{
			Name: "C2",
		},
	})

	tbl.AppendHeader(table.Row{
		"C1",
		"C2",
	})

	tbl.AppendRows([]table.Row{
		{
			"very long row value that wraps",
			"x",
		},
		{
			"very long row value that wraps",
			"y",
		},
	})

	tblstring := tbl.Render()
	fmt.Println(tblstring)
}

Output:

=== RUN   TestWrapWithVerticalMerge
+------------+----+
| C1         | C2 |
+------------+----+
| very long  | x  |
| row value  |    |
| that wraps |    |
|            | y  |
|            |    |
|            |    |
+------------+----+

Expected behavior
I would expect the output to look more like the following, though I'm open to changes on the specifics. The main point is that, similar to #226, unnecessary space is left because it seems like the merging thinks the original row value (pre merge) is still present.

+------------+----+
| C1         | C2 |
+------------+----+
| very long  | x  |
| row value  | y  |
| that wraps |    |
+------------+----+

Software (please complete the following information):

My go.mod has:

go 1.16

require (
	github.com/jedib0t/go-pretty/v6 v6.4.6
)
  • OS: Linux
  • GoLang Version: go version go1.20.1 linux/amd64
@jedib0t
Copy link
Owner

jedib0t commented Mar 13, 2023

Hey sorry for the late response. This is a known issue, but thanks for bringing it back up. I'll try to spend some time soon to get this fixed.

@jedib0t jedib0t self-assigned this Mar 13, 2023
@jedib0t jedib0t added the enhancement New feature or request label Jan 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants