mirror of
https://github.com/charmbracelet/gum
synced 2024-06-20 06:25:08 +02:00
fix: default timeout selection
This commit is contained in:
parent
6c9c1eb8eb
commit
8879049985
|
@ -14,15 +14,16 @@ import (
|
||||||
// action with an affirmative or negative answer.
|
// action with an affirmative or negative answer.
|
||||||
func (o Options) Run() error {
|
func (o Options) Run() error {
|
||||||
m, err := tea.NewProgram(model{
|
m, err := tea.NewProgram(model{
|
||||||
affirmative: o.Affirmative,
|
affirmative: o.Affirmative,
|
||||||
negative: o.Negative,
|
negative: o.Negative,
|
||||||
confirmation: o.Default,
|
confirmation: o.Default,
|
||||||
timeout: o.Timeout,
|
defaultSelection: o.Default,
|
||||||
hasTimeout: o.Timeout > 0,
|
timeout: o.Timeout,
|
||||||
prompt: o.Prompt,
|
hasTimeout: o.Timeout > 0,
|
||||||
selectedStyle: o.SelectedStyle.ToLipgloss(),
|
prompt: o.Prompt,
|
||||||
unselectedStyle: o.UnselectedStyle.ToLipgloss(),
|
selectedStyle: o.SelectedStyle.ToLipgloss(),
|
||||||
promptStyle: o.PromptStyle.ToLipgloss(),
|
unselectedStyle: o.UnselectedStyle.ToLipgloss(),
|
||||||
|
promptStyle: o.PromptStyle.ToLipgloss(),
|
||||||
}, tea.WithOutput(os.Stderr)).Run()
|
}, tea.WithOutput(os.Stderr)).Run()
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -88,6 +88,7 @@ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
|
||||||
case tickMsg:
|
case tickMsg:
|
||||||
if m.timeout <= 0 {
|
if m.timeout <= 0 {
|
||||||
m.quitting = true
|
m.quitting = true
|
||||||
|
m.confirmation = m.defaultSelection
|
||||||
return m, tea.Quit
|
return m, tea.Quit
|
||||||
}
|
}
|
||||||
m.timeout -= tickInterval
|
m.timeout -= tickInterval
|
||||||
|
|
Loading…
Reference in a new issue