diff --git a/accessibility/accessibility.go b/accessibility/accessibility.go index 60accc1f..83e3e552 100644 --- a/accessibility/accessibility.go +++ b/accessibility/accessibility.go @@ -42,7 +42,9 @@ func parseBool(s string) (bool, error) { } } - for _, n := range []string{"n", "no"} { + // As a special case, we default to "" to no since the usage of this + // function suggests N is the default. + for _, n := range []string{"", "n", "no"} { if n == s { return false, nil } @@ -78,7 +80,12 @@ func PromptString(prompt string, validator func(input string) error) string { for !valid { fmt.Print(prompt) - _ = scanner.Scan() + if !scanner.Scan() { + // no way to bubble up errors or signal cancellation + // but the program is probably not continuing if + // stdin sent EOF + break + } input = scanner.Text() err := validator(input) diff --git a/examples/go.mod b/examples/go.mod index f1c4c83d..3cfad739 100644 --- a/examples/go.mod +++ b/examples/go.mod @@ -4,7 +4,7 @@ go 1.22 require ( github.com/charmbracelet/bubbles v0.20.0 - github.com/charmbracelet/bubbletea v1.2.3 + github.com/charmbracelet/bubbletea v1.2.4 github.com/charmbracelet/glamour v0.8.0 github.com/charmbracelet/huh v0.0.0-00010101000000-000000000000 github.com/charmbracelet/huh/spinner v0.0.0-00010101000000-000000000000 diff --git a/examples/go.sum b/examples/go.sum index 4041ccbc..b13c13c3 100644 --- a/examples/go.sum +++ b/examples/go.sum @@ -20,8 +20,8 @@ github.com/catppuccin/go v0.2.0 h1:ktBeIrIP42b/8FGiScP9sgrWOss3lw0Z5SktRoithGA= github.com/catppuccin/go v0.2.0/go.mod h1:8IHJuMGaUUjQM82qBrGNBv7LFq6JI3NnQCF6MOlZjpc= github.com/charmbracelet/bubbles v0.20.0 h1:jSZu6qD8cRQ6k9OMfR1WlM+ruM8fkPWkHvQWD9LIutE= github.com/charmbracelet/bubbles v0.20.0/go.mod h1:39slydyswPy+uVOHZ5x/GjwVAFkCsV8IIVy+4MhzwwU= -github.com/charmbracelet/bubbletea v1.2.3 h1:d9MdMsANIYZB5pE1KkRqaUV6GfsiWm+/9z4fTuGVm9I= -github.com/charmbracelet/bubbletea v1.2.3/go.mod h1:Qr6fVQw+wX7JkWWkVyXYk/ZUQ92a6XNekLXa3rR18MM= +github.com/charmbracelet/bubbletea v1.2.4 h1:KN8aCViA0eps9SCOThb2/XPIlea3ANJLUkv3KnQRNCE= +github.com/charmbracelet/bubbletea v1.2.4/go.mod h1:Qr6fVQw+wX7JkWWkVyXYk/ZUQ92a6XNekLXa3rR18MM= github.com/charmbracelet/glamour v0.8.0 h1:tPrjL3aRcQbn++7t18wOpgLyl8wrOHUEDS7IZ68QtZs= github.com/charmbracelet/glamour v0.8.0/go.mod h1:ViRgmKkf3u5S7uakt2czJ272WSg2ZenlYEZXT2x7Bjw= github.com/charmbracelet/harmonica v0.2.0 h1:8NxJWRWg/bzKqqEaaeFNipOu77YR5t8aSwG4pgaUBiQ= diff --git a/field_input.go b/field_input.go index db1d4240..93a1513b 100644 --- a/field_input.go +++ b/field_input.go @@ -342,11 +342,6 @@ func (i *Input) Update(msg tea.Msg) (tea.Model, tea.Cmd) { switch { case key.Matches(msg, i.keymap.Prev): - value := i.textinput.Value() - i.err = i.validate(value) - if i.err != nil { - return i, nil - } cmds = append(cmds, PrevField) case key.Matches(msg, i.keymap.Next, i.keymap.Submit): value := i.textinput.Value()