From 9dbf6b02d24b52ae43e36905bbb1e83087e1dfe9 Mon Sep 17 00:00:00 2001 From: Junegunn Choi Date: Sun, 11 Jan 2015 23:49:12 +0900 Subject: Fix race conditions - Wait for completions of goroutines when cancelling a search - Remove shared access to rank field of Item --- src/core.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/core.go') diff --git a/src/core.go b/src/core.go index 2970038f..ab2a48fa 100644 --- a/src/core.go +++ b/src/core.go @@ -64,7 +64,10 @@ func Run(options *Options) { var chunkList *ChunkList if len(opts.WithNth) == 0 { chunkList = NewChunkList(func(data *string, index int) *Item { - return &Item{text: data, rank: Rank{0, 0, uint32(index)}} + return &Item{ + text: data, + index: uint32(index), + rank: Rank{0, 0, uint32(index)}} }) } else { chunkList = NewChunkList(func(data *string, index int) *Item { @@ -72,6 +75,7 @@ func Run(options *Options) { item := Item{ text: Transform(tokens, opts.WithNth).whole, origText: data, + index: uint32(index), rank: Rank{0, 0, uint32(index)}} return &item }) -- cgit v1.2.3