diff --git a/Changes b/Changes index b3a9cb8b..513cc326 100644 --- a/Changes +++ b/Changes @@ -1,6 +1,10 @@ Changes ======= +v0.4.5 - Unreleased + Bugs/Fixes + * v0.4.4 broke --select-1 :/ (#363) + v0.4.4 - 23 Oct 2016 Bugs/Fixes * Fix to force a redraw of the screen when the query becomes empty (#346) diff --git a/peco_test.go b/peco_test.go index bc8a05aa..0fa52afd 100644 --- a/peco_test.go +++ b/peco_test.go @@ -250,3 +250,28 @@ func TestApplyConfig(t *testing.T) { return } } + +func TestGHIssue363(t *testing.T) { + ctx, cancel := context.WithTimeout(context.Background(), time.Second) + defer cancel() + + p := newPeco() + p.Argv = []string{"--select-1"} + p.Stdin = bytes.NewBufferString("foo\n") + var out bytes.Buffer + p.Stdout = &out + if !assert.NoError(t, p.Run(ctx), "p.Run should succeed") { + return + } + + select { + case <-ctx.Done(): + t.Errorf("we should get here before being canceled") + return + default: + } + + if !assert.NotEqual(t, "foo\n", out.String(), "output should match") { + return + } +} diff --git a/source.go b/source.go index 9587a4d9..237b6658 100644 --- a/source.go +++ b/source.go @@ -97,7 +97,7 @@ func (s *Source) Setup(ctx context.Context, state *Peco) { state.Hub().SendStatusMsg("Waiting for input...") readCount := 0 - for { + for loop := true; loop; { select { case <-ctx.Done(): if pdebug.Enabled { @@ -109,6 +109,7 @@ func (s *Source) Setup(ctx context.Context, state *Peco) { if pdebug.Enabled { pdebug.Printf("No more lines to read...") } + loop = false break }