Skip to content

Commit

Permalink
fix: empty search list when delete last one;
Browse files Browse the repository at this point in the history
  • Loading branch information
MapoMagpie committed May 22, 2024
1 parent 3c2728c commit 7dd2091
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
1 change: 1 addition & 0 deletions core/core.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
14 changes: 7 additions & 7 deletions dict/matcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down

0 comments on commit 7dd2091

Please sign in to comment.