fix: searching should clear options when selected

This commit is contained in:
Maas Lalani 2022-07-06 12:51:12 -04:00
parent 09feddcc61
commit 12cde525ee
No known key found for this signature in database
GPG key ID: 5A6ED5CBF1A0A000
3 changed files with 9 additions and 3 deletions

View file

@ -2,10 +2,13 @@ package main
import (
"github.com/alecthomas/kong"
"github.com/charmbracelet/lipgloss"
"github.com/charmbracelet/sodapop/internal/stdin"
"github.com/muesli/termenv"
)
func main() {
lipgloss.SetColorProfile(termenv.ANSI256)
pop := &Pop{}
ctx := kong.Parse(pop,
kong.Name("pop"),

View file

@ -10,14 +10,11 @@ import (
"github.com/charmbracelet/lipgloss"
"github.com/charmbracelet/sodapop/internal/log"
"github.com/charmbracelet/sodapop/internal/stdin"
"github.com/muesli/termenv"
)
// Run provides a shell script interface for the search bubble.
// https://github.com/charmbracelet/bubbles/search
func (o Options) Run() {
lipgloss.SetColorProfile(termenv.ANSI256)
i := textinput.New()
i.Focus()

View file

@ -17,10 +17,15 @@ type model struct {
selected int
indicator string
height int
quitting bool
}
func (m model) Init() tea.Cmd { return nil }
func (m model) View() string {
if m.quitting {
return ""
}
var s strings.Builder
// Since there are matches, display them so that the user can see, in real
@ -73,6 +78,7 @@ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
case tea.KeyMsg:
switch msg.String() {
case "ctrl+c", "esc", "enter":
m.quitting = true
return m, tea.Quit
case "ctrl+n":
m.selected = clamp(0, len(m.matches)-1, m.selected+1)