mirror of
https://github.com/junegunn/fzf.git
synced 2025-08-14 19:55:49 -07:00
This command would cause a deadlock and make fzf crash: fzf --bind 'start:reload:ls' --height ~100% Because, 1. 'start' event is handled by Terminal 2. When 'reload' is bound to 'start', fzf avoids starting the initial reader 3. Terminal waits for the initial input to find the right height when adaptive height is used 4. Because the initial reader is not started, Terminal never gets the initial list 5. No chance to trigger 'start:reload', hence deadlock This commit fixes the above problem by extracting the reload command bound to 'start' event and starting the initial reader with that command instead of letting Terminal start it. This commit also makes the environment variables available to $FZF_DEFAULT_COMMAND. FZF_DEFAULT_COMMAND='echo $FZF_QUERY' fzf --query foo Fix #3944
76 lines
1.7 KiB
Go
76 lines
1.7 KiB
Go
package fzf
|
|
|
|
import (
|
|
"math"
|
|
"time"
|
|
|
|
"github.com/junegunn/fzf/src/util"
|
|
)
|
|
|
|
const (
|
|
// Core
|
|
coordinatorDelayMax time.Duration = 100 * time.Millisecond
|
|
coordinatorDelayStep time.Duration = 10 * time.Millisecond
|
|
|
|
// Reader
|
|
readerBufferSize = 64 * 1024
|
|
readerSlabSize = 128 * 1024
|
|
readerPollIntervalMin = 10 * time.Millisecond
|
|
readerPollIntervalStep = 5 * time.Millisecond
|
|
readerPollIntervalMax = 50 * time.Millisecond
|
|
|
|
// Terminal
|
|
initialDelay = 20 * time.Millisecond
|
|
initialDelayTac = 100 * time.Millisecond
|
|
spinnerDuration = 100 * time.Millisecond
|
|
previewCancelWait = 500 * time.Millisecond
|
|
previewChunkDelay = 100 * time.Millisecond
|
|
previewDelayed = 500 * time.Millisecond
|
|
maxPatternLength = 300
|
|
maxMulti = math.MaxInt32
|
|
|
|
// Matcher
|
|
numPartitionsMultiplier = 8
|
|
maxPartitions = 32
|
|
progressMinDuration = 200 * time.Millisecond
|
|
|
|
// Capacity of each chunk
|
|
chunkSize int = 100
|
|
|
|
// Pre-allocated memory slices to minimize GC
|
|
slab16Size int = 100 * 1024 // 200KB * 32 = 12.8MB
|
|
slab32Size int = 2048 // 8KB * 32 = 256KB
|
|
|
|
// Do not cache results of low selectivity queries
|
|
queryCacheMax int = chunkSize / 5
|
|
|
|
// Not to cache mergers with large lists
|
|
mergerCacheMax int = 100000
|
|
|
|
// History
|
|
defaultHistoryMax int = 1000
|
|
|
|
// Jump labels
|
|
defaultJumpLabels string = "asdfghjklqwertyuiopzxcvbnm1234567890ASDFGHJKLQWERTYUIOPZXCVBNM`~;:,<.>/?'\"!@#$%^&*()[{]}-_=+"
|
|
)
|
|
|
|
// fzf events
|
|
const (
|
|
EvtReadNew util.EventType = iota
|
|
EvtReadFin
|
|
EvtSearchNew
|
|
EvtSearchProgress
|
|
EvtSearchFin
|
|
EvtHeader
|
|
EvtReady
|
|
EvtQuit
|
|
)
|
|
|
|
const (
|
|
ExitOk = 0
|
|
ExitNoMatch = 1
|
|
ExitError = 2
|
|
ExitBecome = 126
|
|
ExitInterrupt = 130
|
|
)
|