mirror of https://github.com/rivo/tview.git
increment lastColumn when inserting columns
This commit is contained in:
parent
7dfff1ce78
commit
ead28d0e8f
5
table.go
5
table.go
|
@ -346,6 +346,7 @@ func (t *tableDefaultContent) InsertRow(row int) {
|
||||||
|
|
||||||
// InsertColumn inserts a new column at the given position.
|
// InsertColumn inserts a new column at the given position.
|
||||||
func (t *tableDefaultContent) InsertColumn(column int) {
|
func (t *tableDefaultContent) InsertColumn(column int) {
|
||||||
|
var didInsert bool
|
||||||
for row := range t.cells {
|
for row := range t.cells {
|
||||||
if column >= len(t.cells[row]) {
|
if column >= len(t.cells[row]) {
|
||||||
continue
|
continue
|
||||||
|
@ -353,6 +354,10 @@ func (t *tableDefaultContent) InsertColumn(column int) {
|
||||||
t.cells[row] = append(t.cells[row], nil) // Extend by one.
|
t.cells[row] = append(t.cells[row], nil) // Extend by one.
|
||||||
copy(t.cells[row][column+1:], t.cells[row][column:]) // Shift to the right.
|
copy(t.cells[row][column+1:], t.cells[row][column:]) // Shift to the right.
|
||||||
t.cells[row][column] = &TableCell{} // New element is an uninitialized table cell.
|
t.cells[row][column] = &TableCell{} // New element is an uninitialized table cell.
|
||||||
|
didInsert = true
|
||||||
|
}
|
||||||
|
if didInsert {
|
||||||
|
t.lastColumn++
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue