mirror of
https://github.com/charmbracelet/gum
synced 2024-06-29 10:40:28 +02:00
fix: searching should clear options when selected
This commit is contained in:
parent
09feddcc61
commit
12cde525ee
3
main.go
3
main.go
|
@ -2,10 +2,13 @@ package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/alecthomas/kong"
|
"github.com/alecthomas/kong"
|
||||||
|
"github.com/charmbracelet/lipgloss"
|
||||||
"github.com/charmbracelet/sodapop/internal/stdin"
|
"github.com/charmbracelet/sodapop/internal/stdin"
|
||||||
|
"github.com/muesli/termenv"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
lipgloss.SetColorProfile(termenv.ANSI256)
|
||||||
pop := &Pop{}
|
pop := &Pop{}
|
||||||
ctx := kong.Parse(pop,
|
ctx := kong.Parse(pop,
|
||||||
kong.Name("pop"),
|
kong.Name("pop"),
|
||||||
|
|
|
@ -10,14 +10,11 @@ import (
|
||||||
"github.com/charmbracelet/lipgloss"
|
"github.com/charmbracelet/lipgloss"
|
||||||
"github.com/charmbracelet/sodapop/internal/log"
|
"github.com/charmbracelet/sodapop/internal/log"
|
||||||
"github.com/charmbracelet/sodapop/internal/stdin"
|
"github.com/charmbracelet/sodapop/internal/stdin"
|
||||||
"github.com/muesli/termenv"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// Run provides a shell script interface for the search bubble.
|
// Run provides a shell script interface for the search bubble.
|
||||||
// https://github.com/charmbracelet/bubbles/search
|
// https://github.com/charmbracelet/bubbles/search
|
||||||
func (o Options) Run() {
|
func (o Options) Run() {
|
||||||
lipgloss.SetColorProfile(termenv.ANSI256)
|
|
||||||
|
|
||||||
i := textinput.New()
|
i := textinput.New()
|
||||||
i.Focus()
|
i.Focus()
|
||||||
|
|
||||||
|
|
|
@ -17,10 +17,15 @@ type model struct {
|
||||||
selected int
|
selected int
|
||||||
indicator string
|
indicator string
|
||||||
height int
|
height int
|
||||||
|
quitting bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m model) Init() tea.Cmd { return nil }
|
func (m model) Init() tea.Cmd { return nil }
|
||||||
func (m model) View() string {
|
func (m model) View() string {
|
||||||
|
if m.quitting {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
var s strings.Builder
|
var s strings.Builder
|
||||||
|
|
||||||
// Since there are matches, display them so that the user can see, in real
|
// 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:
|
case tea.KeyMsg:
|
||||||
switch msg.String() {
|
switch msg.String() {
|
||||||
case "ctrl+c", "esc", "enter":
|
case "ctrl+c", "esc", "enter":
|
||||||
|
m.quitting = true
|
||||||
return m, tea.Quit
|
return m, tea.Quit
|
||||||
case "ctrl+n":
|
case "ctrl+n":
|
||||||
m.selected = clamp(0, len(m.matches)-1, m.selected+1)
|
m.selected = clamp(0, len(m.matches)-1, m.selected+1)
|
||||||
|
|
Loading…
Reference in a new issue