Skip to content
Myr

fix: skip input reader restore when input is disabled (#1680)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by chaoliang yan · committed by GitHub · parent fdcd0cf · Browse files · 2 files+36 added−2 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Trailers

  • Co-authored-by: lawrence3699 <lawrence3699@users.noreply.github.com>

Diff stats

2 files+36 added−2 removed

  • other:+36 added−2 removed

2 files+36 added−2 removed

modified:exec_test.go+32 added
12 unmodified lines
13 cmd string14 err error15}1617type testExecNoInputModel struct{ testExecModel }1819func (m *testExecModel) Init() Cmd {20 c := exec.Command(m.cmd) //nolint:gosec21 return ExecProcess(c, func(err error) Msg {22 return execFinishedMsg{err}23 })24}2526func (m *testExecNoInputModel) Init() Cmd {27 return ExecProcess(successExecCommand(), func(err error) Msg {28 return execFinishedMsg{err}29 })30}3132func (m *testExecModel) Update(msg Msg) (Model, Cmd) {33 switch msg := msg.(type) {34 case execFinishedMsg:35 if msg.err != nil {
13 unmodified lines
49 renderer50 calledReset bool51}5253func successExecCommand() *exec.Cmd {54 if runtime.GOOS == "windows" {55 return exec.Command("cmd", "/c", "exit 0")56 }57 return exec.Command("true")58}5960func TestTeaExec(t *testing.T) {61 type test struct {62 name string63 cmd string
51 unmodified lines
115 }116 })117 }118}119120func TestTeaExecWithNilInput(t *testing.T) {121 var buf bytes.Buffer122123 m := &testExecNoInputModel{}124 p := NewProgram(m,125 WithInput(nil),126 WithOutput(&buf),127 )128129 if _, err := p.Run(); err != nil {130 t.Fatal(err)131 }132 if m.err != nil {133 t.Fatalf("expected no error, got %v", m.err)134 }135}
modified:tea.go+4 added-2 removed
1345 unmodified lines
13461347 if err := p.initTerminal(); err != nil {1348 return err1349 }1350 if p.input != nil {1350 if err := p.initInputReader(false); err != nil {1351 return err1351 if err := p.initInputReader(false); err != nil {1352 return err1353 }1354 }13551356 p.startRenderer()1357
82 unmodified lines