|
|
@ -138,7 +138,9 @@ func Run(opts *Options, version string, revision string) {
|
|
|
|
opts.Fuzzy, opts.FuzzyAlgo, opts.Extended, opts.Case, opts.Normalize, forward, withPos,
|
|
|
|
opts.Fuzzy, opts.FuzzyAlgo, opts.Extended, opts.Case, opts.Normalize, forward, withPos,
|
|
|
|
opts.Filter == nil, opts.Nth, opts.Delimiter, runes)
|
|
|
|
opts.Filter == nil, opts.Nth, opts.Delimiter, runes)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
matcher := NewMatcher(patternBuilder, sort, opts.Tac, eventBox)
|
|
|
|
inputRevision := 0
|
|
|
|
|
|
|
|
snapshotRevision := 0
|
|
|
|
|
|
|
|
matcher := NewMatcher(patternBuilder, sort, opts.Tac, eventBox, inputRevision)
|
|
|
|
|
|
|
|
|
|
|
|
// Filtering mode
|
|
|
|
// Filtering mode
|
|
|
|
if opts.Filter != nil {
|
|
|
|
if opts.Filter != nil {
|
|
|
@ -209,8 +211,6 @@ func Run(opts *Options, version string, revision string) {
|
|
|
|
|
|
|
|
|
|
|
|
// Event coordination
|
|
|
|
// Event coordination
|
|
|
|
reading := true
|
|
|
|
reading := true
|
|
|
|
clearCache := util.Once(false)
|
|
|
|
|
|
|
|
clearSelection := util.Once(false)
|
|
|
|
|
|
|
|
ticks := 0
|
|
|
|
ticks := 0
|
|
|
|
var nextCommand *string
|
|
|
|
var nextCommand *string
|
|
|
|
eventBox.Watch(EvtReadNew)
|
|
|
|
eventBox.Watch(EvtReadNew)
|
|
|
@ -234,17 +234,17 @@ func Run(opts *Options, version string, revision string) {
|
|
|
|
var count int
|
|
|
|
var count int
|
|
|
|
restart := func(command string) {
|
|
|
|
restart := func(command string) {
|
|
|
|
reading = true
|
|
|
|
reading = true
|
|
|
|
clearCache = util.Once(true)
|
|
|
|
|
|
|
|
clearSelection = util.Once(true)
|
|
|
|
|
|
|
|
chunkList.Clear()
|
|
|
|
chunkList.Clear()
|
|
|
|
itemIndex = 0
|
|
|
|
itemIndex = 0
|
|
|
|
|
|
|
|
inputRevision++
|
|
|
|
header = make([]string, 0, opts.HeaderLines)
|
|
|
|
header = make([]string, 0, opts.HeaderLines)
|
|
|
|
go reader.restart(command)
|
|
|
|
go reader.restart(command)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for {
|
|
|
|
for {
|
|
|
|
delay := true
|
|
|
|
delay := true
|
|
|
|
ticks++
|
|
|
|
ticks++
|
|
|
|
input := func(reloaded bool) []rune {
|
|
|
|
input := func() []rune {
|
|
|
|
|
|
|
|
reloaded := snapshotRevision != inputRevision
|
|
|
|
paused, input := terminal.Input()
|
|
|
|
paused, input := terminal.Input()
|
|
|
|
if reloaded && paused {
|
|
|
|
if reloaded && paused {
|
|
|
|
query = []rune{}
|
|
|
|
query = []rune{}
|
|
|
@ -277,18 +277,18 @@ func Run(opts *Options, version string, revision string) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if !useSnapshot {
|
|
|
|
if !useSnapshot {
|
|
|
|
snapshot, count = chunkList.Snapshot()
|
|
|
|
snapshot, count = chunkList.Snapshot()
|
|
|
|
|
|
|
|
snapshotRevision = inputRevision
|
|
|
|
}
|
|
|
|
}
|
|
|
|
total = count
|
|
|
|
total = count
|
|
|
|
terminal.UpdateCount(total, !reading, value.(*string))
|
|
|
|
terminal.UpdateCount(total, !reading, value.(*string))
|
|
|
|
if opts.Sync {
|
|
|
|
if opts.Sync {
|
|
|
|
opts.Sync = false
|
|
|
|
opts.Sync = false
|
|
|
|
terminal.UpdateList(PassMerger(&snapshot, opts.Tac), false)
|
|
|
|
terminal.UpdateList(PassMerger(&snapshot, opts.Tac, snapshotRevision))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if heightUnknown && !deferred {
|
|
|
|
if heightUnknown && !deferred {
|
|
|
|
determine(!reading)
|
|
|
|
determine(!reading)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
reset := !useSnapshot && clearCache()
|
|
|
|
matcher.Reset(snapshot, input(), false, !reading, sort, snapshotRevision)
|
|
|
|
matcher.Reset(snapshot, input(reset), false, !reading, sort, reset)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
case EvtSearchNew:
|
|
|
|
case EvtSearchNew:
|
|
|
|
var command *string
|
|
|
|
var command *string
|
|
|
@ -313,17 +313,16 @@ func Run(opts *Options, version string, revision string) {
|
|
|
|
if !changed {
|
|
|
|
if !changed {
|
|
|
|
break
|
|
|
|
break
|
|
|
|
}
|
|
|
|
}
|
|
|
|
reset := false
|
|
|
|
|
|
|
|
if !useSnapshot {
|
|
|
|
if !useSnapshot {
|
|
|
|
newSnapshot, _ := chunkList.Snapshot()
|
|
|
|
newSnapshot, _ := chunkList.Snapshot()
|
|
|
|
// We want to avoid showing empty list when reload is triggered
|
|
|
|
// We want to avoid showing empty list when reload is triggered
|
|
|
|
// and the query string is changed at the same time i.e. command != nil && changed
|
|
|
|
// and the query string is changed at the same time i.e. command != nil && changed
|
|
|
|
if command == nil || len(newSnapshot) > 0 {
|
|
|
|
if command == nil || len(newSnapshot) > 0 {
|
|
|
|
snapshot = newSnapshot
|
|
|
|
snapshot = newSnapshot
|
|
|
|
reset = clearCache()
|
|
|
|
snapshotRevision = inputRevision
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
matcher.Reset(snapshot, input(reset), true, !reading, sort, reset)
|
|
|
|
matcher.Reset(snapshot, input(), true, !reading, sort, snapshotRevision)
|
|
|
|
delay = false
|
|
|
|
delay = false
|
|
|
|
|
|
|
|
|
|
|
|
case EvtSearchProgress:
|
|
|
|
case EvtSearchProgress:
|
|
|
@ -363,7 +362,7 @@ func Run(opts *Options, version string, revision string) {
|
|
|
|
determine(val.final)
|
|
|
|
determine(val.final)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
terminal.UpdateList(val, clearSelection())
|
|
|
|
terminal.UpdateList(val)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|