Skip to content

Commit

Permalink
Fix col length check
Browse files Browse the repository at this point in the history
Signed-off-by: house <[email protected]>
  • Loading branch information
dr-housemd committed Dec 17, 2024
1 parent b2c6357 commit 54a985b
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions cmd/search/versionList.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ import (
"github.com/buildsafedev/bsf/pkg/clients/search"
)

const (
totalCols = 6
)

type versionListModel struct {
pkgList list.Model
versionTable table.Model
Expand Down Expand Up @@ -45,14 +49,13 @@ func convFPR2Rows(versions *buildsafev1.FetchPackagesResponse) []table.Row {

// initVersionTable initializes the version table
func initVersionTable(searchList list.Model, versions *buildsafev1.FetchPackagesResponse) *versionListModel {
cols := 6
columns := []table.Column{
{Title: "Name", Width: frameWidth / cols},
{Title: "Version", Width: frameWidth / cols},
{Title: "License", Width: frameWidth / cols},
{Title: "Free", Width: frameWidth / cols},
{Title: "Homepage", Width: frameWidth * 2 / cols},
{Title: "Date", Width: frameWidth / cols},
{Title: "Name", Width: frameWidth / totalCols},
{Title: "Version", Width: frameWidth / totalCols},
{Title: "License", Width: frameWidth / totalCols},
{Title: "Free", Width: frameWidth / totalCols},
{Title: "Homepage", Width: frameWidth * 2 / totalCols},
{Title: "Date", Width: frameWidth / totalCols},
}

rows := convFPR2Rows(versions)
Expand Down Expand Up @@ -112,7 +115,7 @@ func (m versionListModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
break
}
row := m.versionTable.SelectedRow()
if len(row) != 5 {
if len(row) != totalCols {
// TODO: return errMsg
return m, tea.Quit
}
Expand Down

0 comments on commit 54a985b

Please sign in to comment.