From 7dd20914fa1f3e8ef39e17a76aceaed154531d3b Mon Sep 17 00:00:00 2001 From: MapoMagpie Date: Wed, 22 May 2024 14:44:55 +0800 Subject: [PATCH] fix: empty search list when delete last one; --- core/core.go | 1 + dict/matcher.go | 14 +++++++------- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/core/core.go b/core/core.go index dc57dad..babe59e 100644 --- a/core/core.go +++ b/core/core.go @@ -289,6 +289,7 @@ func Start(opts *Options) { list[i] = entry } listManager.AppendList(list) + // log.Println("list manager append list: ", len(list)) hasAppend = true case <-timer.C: // debounce, if appended then flush if hasAppend { diff --git a/dict/matcher.go b/dict/matcher.go index 6c46702..4b17dc7 100644 --- a/dict/matcher.go +++ b/dict/matcher.go @@ -76,20 +76,20 @@ func (m *CacheMatcher) Search(key []rune, list []*Entry, resultChan chan<- []*Ma if done { return } - if entry.modType == DELETE { - continue - } - result, _ := algo.FuzzyMatchV2(false, true, true, &entry.text, key, false, slab) - if result.Score > 0 { - matched = append(matched, &MatchResult{entry, result}) + if entry.modType != DELETE { + result, _ := algo.FuzzyMatchV2(false, true, true, &entry.text, key, false, slab) + if result.Score > 0 { + matched = append(matched, &MatchResult{entry, result}) + } } if (idx%chunkSize == 0 && idx != 0) || idx == listLen-1 { m2 := matched[lastIdx:] resultChan <- m2 + // log.Printf("Cache Matcher Search: Key: %s, Send result: %d", string(key), len(m2)) lastIdx = len(matched) } } - + // log.Printf("Cache Matcher Search: Key: %s, List Len: %d, Cached: %v, Matched: %d", string(key), listLen, cache != nil, len(matched)) if m.cache == nil { m.cache = make(map[string][]*MatchResult) }