summaryrefslogtreecommitdiffstats
path: root/src/matcher.go
diff options
context:
space:
mode:
authorJunegunn Choi <junegunn.c@gmail.com>2019-11-10 11:36:22 +0900
committerJunegunn Choi <junegunn.c@gmail.com>2019-11-10 11:43:37 +0900
commit78da9287272a0bfa183498c5b2e9fde10a3663a0 (patch)
tree4318915c919024604777e16d49ae14a838564804 /src/matcher.go
parent11962dabba69e706246bfcd54fa42b1e1c6bee8b (diff)
Experimental implementation of "reload" action
# Reload input list with different sources seq 10 | fzf --bind 'ctrl-a:reload(seq 100),ctrl-b:reload(seq 1000)' # Reload as you type seq 10 | fzf --bind 'change:reload:seq {q}' --phony # Integration with ripgrep RG_PREFIX="rg --column --line-number --no-heading --color=always --smart-case " INITIAL_QUERY="" FZF_DEFAULT_COMMAND="$RG_PREFIX '$INITIAL_QUERY'" \ fzf --bind "change:reload:$RG_PREFIX {q} || true" \ --ansi --phony --query "$INITIAL_QUERY" Close #751 Close #965 Close #974 Close #1736 Related #1723
Diffstat (limited to 'src/matcher.go')
-rw-r--r--src/matcher.go15
1 files changed, 8 insertions, 7 deletions
diff --git a/src/matcher.go b/src/matcher.go
index 69250873..22aa819c 100644
--- a/src/matcher.go
+++ b/src/matcher.go
@@ -12,10 +12,11 @@ import (
// MatchRequest represents a search request
type MatchRequest struct {
- chunks []*Chunk
- pattern *Pattern
- final bool
- sort bool
+ chunks []*Chunk
+ pattern *Pattern
+ final bool
+ sort bool
+ clearCache bool
}
// Matcher is responsible for performing search
@@ -69,7 +70,7 @@ func (m *Matcher) Loop() {
events.Clear()
})
- if request.sort != m.sort {
+ if request.sort != m.sort || request.clearCache {
m.sort = request.sort
m.mergerCache = make(map[string]*Merger)
clearChunkCache()
@@ -221,7 +222,7 @@ func (m *Matcher) scan(request MatchRequest) (*Merger, bool) {
}
// Reset is called to interrupt/signal the ongoing search
-func (m *Matcher) Reset(chunks []*Chunk, patternRunes []rune, cancel bool, final bool, sort bool) {
+func (m *Matcher) Reset(chunks []*Chunk, patternRunes []rune, cancel bool, final bool, sort bool, clearCache bool) {
pattern := m.patternBuilder(patternRunes)
var event util.EventType
@@ -230,5 +231,5 @@ func (m *Matcher) Reset(chunks []*Chunk, patternRunes []rune, cancel bool, final
} else {
event = reqRetry
}
- m.reqBox.Set(event, MatchRequest{chunks, pattern, final, sort && pattern.sortable})
+ m.reqBox.Set(event, MatchRequest{chunks, pattern, final, sort && pattern.sortable, clearCache})
}