charmbracelet / lipgloss

Style definitions for nice terminal layouts 👄
MIT License
8.22k stars 231 forks source link

A table with no outside border, but internal borders, does not render correctly #355

Open SVendittelli opened 3 months ago

SVendittelli commented 3 months ago

Describe the bug When rendering a table with no outside borders (i.e. top, bottom, left, and right are disabled) and internal borders enabled (i.e. row and column are enabled), the borders do not align correctly. Extra characters are rendered for the horizontal borders.

Setup Please complete the following information along with version numbers, if applicable.

To Reproduce Steps to reproduce the behavior:

  1. Create a new go module (mkdir table && cd table && go mod init table)
  2. Create a main.go with the contents below
  3. Run go get . to pull dependencies
  4. Run go run .
  5. Observe incorrect rendering:
1│2│3
├─┼─┼─┤
4│5│6
├─┼─┼─┤
7│8│9

Source Code main.go

package main

import (
    "fmt"

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

func main() {

    board := [][]string{
        {"1", "2", "3"},
        {"4", "5", "6"},
        {"7", "8", "9"},
    }

    t := table.New().
        Border(lipgloss.NormalBorder()).
        BorderRow(true).
        BorderColumn(true).
        BorderTop(false).
        BorderBottom(false).
        BorderLeft(false).
        BorderRight(false).
        Rows(board...)

    fmt.Println(t.Render())
}

Expected behavior The additional characters ( and ) would not be rendered, resulting in:

1│2│3
─┼─┼─
4│5│6
─┼─┼─
7│8│9

Screenshots Screenshot 2024-08-23 170542

Additional context This is inconsistent with the type of border, I have included a list of them all below:

BlockBorder:

1█2█3
███
4█5█6
███
7█8█9

DoubleBorder:

1║2║3
╠═╬═╬═╣
4║5║6
╠═╬═╬═╣
7║8║9

HiddenBorder:

1 2 3

4 5 6

7 8 9

InnerHalfBlockBorder:

1▐2▐3
▀▀▀
4▐5▐6
▀▀▀
7▐8▐9

NormalBorder:

1│2│3
├─┼─┼─┤
4│5│6
├─┼─┼─┤
7│8│9

OuterHalfBlockBorder:

1▌2▌3
▄▄▄
4▌5▌6
▄▄▄
7▌8▌9

RoundedBorder:

1│2│3
├─┼─┼─┤
4│5│6
├─┼─┼─┤
7│8│9

ThickBorder:

1┃2┃3
┣━╋━╋━┫
4┃5┃6
┣━╋━╋━┫
7┃8┃9