-
Notifications
You must be signed in to change notification settings - Fork 119
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
The top border line was misaligned when title was added #220
Comments
This sounds like a bug. Lemme take a look. |
I'm not able to reproduce this bug @HappyStu. This is the code I used: package main
import (
"fmt"
"os"
"github.com/jedib0t/go-pretty/v6/table"
)
func main() {
tw := table.NewWriter()
tw.AppendHeader(table.Row{"#", "First Name", "Last Name", "Salary"})
tw.AppendRows([]table.Row{
{1, "Arya", "Stark", 3000},
{20, "Jon", "Snow", 2000, "You know nothing, Jon Snow!"},
{300, "Tyrion", "Lannister", 5000},
})
tw.SetOutputMirror(os.Stdout)
tw.SetCaption("The style of this table is %s", table.StyleBold.Name)
tw.SetStyle(table.StyleBold)
tw.SetTitle("Divide!")
tw.Render()
fmt.Println()
tw.SetCaption("The style of this table is %s", table.StyleDefault.Name)
tw.SetStyle(table.StyleDefault)
tw.SetTitle("The style of this table is %s", table.StyleDefault.Name)
tw.Render()
} This is the output I got:
You can try it here: https://go.dev/play/p/I6uxssyXxhN?v=goprev Can you share the code you used to test this? |
This sounds similar to the bug reported in #204 --- do you have a different LANG value?
|
Found the issue. An underlying runewidth library is computing the length of the middle separator in StyleBold |
Reported this in the dependency repo: mattn/go-runewidth#64 |
Thanks for your reply. So I think I can use a fixed symbol width, such as middle separator of 1, to circumvent the problem caused by LANG=zh_CN.UTF-8. Or use English. Thank you again! |
@HappyStu if you are not gonna have East Asian characters in your table contents, you can now use a function I've provided as a workaround for this issue: Tag: https://github.com/jedib0t/go-pretty/releases/tag/v6.3.7 |
Hello! I think this project is very nice. But there is still one small question.
When set the title of table, I find that the top border line is misaligned. For example:
However, when the style is table.StyleDefault, the out of table is normal.
What, may I ask, is the reason for this discrepancy?
environment: Windows, VSCode, Go 1.15
The text was updated successfully, but these errors were encountered: