mirror of
https://github.com/charmbracelet/gum.git
synced 2024-10-26 15:20:05 +03: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 (
|
||||
"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"),
|
||||
|
@ -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()
|
||||
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user