tui: rename
This commit is contained in:
parent
2fed682969
commit
ce7b07ad95
@ -73,7 +73,7 @@ func NewWithGroups(groups []OptionGroup) Model {
|
||||
}
|
||||
|
||||
m.filterItems()
|
||||
m.content.SetContent(m.renderList())
|
||||
m.content.SetContent(m.renderOptionsList())
|
||||
return m
|
||||
}
|
||||
|
||||
@ -113,15 +113,13 @@ func (m *Model) filterItems() {
|
||||
if len(m.filteredIndices) > 0 && prevSelection != nil {
|
||||
// Preserve previous selection if possible
|
||||
for i, filterIdx := range m.filteredIndices {
|
||||
if prevSelection.groupIndex == filterIdx.groupIndex {
|
||||
if prevSelection.optionIndex == filterIdx.optionIndex {
|
||||
if prevSelection.groupIndex == filterIdx.groupIndex && prevSelection.optionIndex == filterIdx.optionIndex {
|
||||
m.selected = i
|
||||
found = true
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if !found {
|
||||
m.selected = 0
|
||||
}
|
||||
@ -180,7 +178,7 @@ func (m *Model) Update(msg tea.Msg) (Model, tea.Cmd) {
|
||||
}
|
||||
|
||||
func (m *Model) refreshContent() {
|
||||
m.content.SetContent(m.renderList())
|
||||
m.content.SetContent(m.renderOptionsList())
|
||||
m.ensureSelectedVisible()
|
||||
}
|
||||
|
||||
@ -219,12 +217,12 @@ func (m *Model) View() string {
|
||||
return lipgloss.JoinVertical(lipgloss.Left, parts...)
|
||||
}
|
||||
|
||||
func (m *Model) renderList() string {
|
||||
var sb strings.Builder
|
||||
func (m *Model) renderOptionsList() string {
|
||||
yOffset := 0
|
||||
lastGroupIndex := -1
|
||||
m.itemYOffsets = make([]int, len(m.filteredIndices))
|
||||
|
||||
var sb strings.Builder
|
||||
for i, idx := range m.filteredIndices {
|
||||
if idx.groupIndex != lastGroupIndex {
|
||||
group := m.optionGroups[idx.groupIndex].Name
|
||||
@ -258,6 +256,5 @@ func (m *Model) renderList() string {
|
||||
sb.WriteRune('\n')
|
||||
}
|
||||
}
|
||||
|
||||
return sb.String()
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user