Skip to content

Commit 470e372

Browse files
committed
WIP
Signed-off-by: Dr. Stefan Schimanski <[email protected]>
1 parent 06256d4 commit 470e372

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

table/resizing.go

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ func (t *Table) resize() {
6060
r.borderRight = t.borderRight
6161
r.borderHeader = t.borderHeader
6262
r.borderRow = t.borderRow
63+
r.showOverflowRow = t.showOverflowRow
6364

6465
var allRows [][]string
6566
if hasHeaders {
@@ -139,14 +140,16 @@ type resizer struct {
139140
borderRight bool
140141
borderHeader bool
141142
borderRow bool
143+
showOverflowRow bool
142144
}
143145

144146
// newResizer creates a new resizer.
145147
func newResizer(tableWidth, tableHeight int, headers []string, rows [][]string) *resizer {
146148
r := &resizer{
147-
tableWidth: tableWidth,
148-
tableHeight: tableHeight,
149-
headers: headers,
149+
tableWidth: tableWidth,
150+
tableHeight: tableHeight,
151+
headers: headers,
152+
showOverflowRow: true,
150153
}
151154

152155
if len(headers) > 0 {
@@ -461,6 +464,9 @@ func (r *resizer) visibleRowIndexes() (firstVisibleRowIndex, lastVisibleRowIndex
461464

462465
rowHeight := r.rowHeights[i] + r.yPaddingForCell(i, 0)
463466
nextRowPadding := r.yPaddingForCell(i+1, 0)
467+
if r.showOverflowRow {
468+
nextRowPadding = 0
469+
}
464470

465471
sum := (printedRows +
466472
rowHeight +

table/table.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,10 @@ func (t *Table) LastVisibleRowIndex() int {
304304
// VisibleRows returns the number of visible rows in the table.
305305
func (t *Table) VisibleRows() int {
306306
if t.lastVisibleRowIndex == -2 {
307-
return t.data.Rows() - t.firstVisibleRowIndex
307+
if t.showOverflowRow {
308+
return t.data.Rows() - t.firstVisibleRowIndex
309+
}
310+
return t.data.Rows() - t.firstVisibleRowIndex + 1
308311
}
309312
return t.lastVisibleRowIndex - t.firstVisibleRowIndex + 1
310313
}

0 commit comments

Comments
 (0)