Skip to content

Commit

Permalink
Merge pull request #364 from peco/topic/issue-363
Browse files Browse the repository at this point in the history
seems like we failed to bail out of the for
  • Loading branch information
lestrrat committed Oct 30, 2016
2 parents 470141f + 0a025f1 commit 9f536a6
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 1 deletion.
4 changes: 4 additions & 0 deletions 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)
Expand Down
25 changes: 25 additions & 0 deletions peco_test.go
Expand Up @@ -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
}
}
3 changes: 2 additions & 1 deletion source.go
Expand Up @@ -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 {
Expand All @@ -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
}

Expand Down

0 comments on commit 9f536a6

Please sign in to comment.