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/pattern.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/pattern.go') diff --git a/src/pattern.go b/src/pattern.go index 31ba8137..2e7d6f91 100644 --- a/src/pattern.go +++ b/src/pattern.go @@ -2,6 +2,7 @@ package fzf import ( "regexp" + "sort" "strings" ) @@ -225,12 +226,14 @@ Loop: } func dupItem(item *Item, offsets []Offset) *Item { + sort.Sort(ByOrder(offsets)) return &Item{ text: item.text, origText: item.origText, transformed: item.transformed, + index: item.index, offsets: offsets, - rank: Rank{0, 0, item.rank.index}} + rank: Rank{0, 0, item.index}} } func (p *Pattern) fuzzyMatch(chunk *Chunk) []*Item { -- cgit v1.2.3