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

Table without border and header truncates last line #261

Open
testinfected opened this issue Feb 13, 2024 · 1 comment
Open

Table without border and header truncates last line #261

testinfected opened this issue Feb 13, 2024 · 1 comment

Comments

@testinfected
Copy link

testinfected commented Feb 13, 2024

Describe the bug
A table which as no border and no header will truncate its last line. In this case the table height is miscalculated.

Additional context
For instance a table with no header and a single line shows nothing.

func (t *Table) computeHeight() int {
	hasHeaders := t.headers != nil && len(t.headers) > 0
	return sum(t.heights) - 1 + btoi(hasHeaders) +
		btoi(t.borderTop) + btoi(t.borderBottom) +
		btoi(t.borderHeader) + t.data.Rows()*btoi(t.borderRow)
}

t.heights in this case is 1 so we end up with a total height of 0. It works with a header because the header height is accounted for twice: once in t.heights and once again with btoi(hasHeaders).
The -1 is the culprit here I guess

@golonzovsky
Copy link

golonzovsky commented Jun 26, 2024

maybe this will help to debug: happens on narrower terminal when table doesent fit from the first run and recalculate logic is triggered.
On a first pass my StyleFunc is getting row/column iteration with rows starting at 1-to-len. With second pass (resize) it goes col/row, but rows are in the range of 0-to-(len-1), which is causing issues for me, but I think its the same bug.

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

No branches or pull requests

2 participants