mirror of
https://github.com/junegunn/fzf.git
synced 2026-03-07 15:42:28 +08:00
In #1061 we changed the default command to retry with a simpler find command with fewer arguments if the first find command failed. This was to support stripped-down verions of find that do not support -fstype argument. However, this caused an unwanted side-effect of yielding duplicate entries when the first command failed after producing some lines. We revert the change in this commit, so the default command will not work with find without -fstype support. But we now print better error message in that case so that the user can set up a working $FZF_DEFAULT_COMMAND. Close #1120 #1167
83 lines
2.0 KiB
Go
83 lines
2.0 KiB
Go
package fzf
|
|
|
|
import (
|
|
"os"
|
|
"time"
|
|
|
|
"github.com/junegunn/fzf/src/util"
|
|
)
|
|
|
|
const (
|
|
// Current version
|
|
version = "0.17.1"
|
|
|
|
// Core
|
|
coordinatorDelayMax time.Duration = 100 * time.Millisecond
|
|
coordinatorDelayStep time.Duration = 10 * time.Millisecond
|
|
|
|
// Reader
|
|
readerBufferSize = 64 * 1024
|
|
readerPollIntervalMin = 10 * time.Millisecond
|
|
readerPollIntervalStep = 5 * time.Millisecond
|
|
readerPollIntervalMax = 50 * time.Millisecond
|
|
|
|
// Terminal
|
|
initialDelay = 20 * time.Millisecond
|
|
initialDelayTac = 100 * time.Millisecond
|
|
spinnerDuration = 200 * time.Millisecond
|
|
|
|
// 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`~;:,<.>/?'\"!@#$%^&*()[{]}-_=+"
|
|
)
|
|
|
|
var defaultCommand string
|
|
|
|
func init() {
|
|
if !util.IsWindows() {
|
|
defaultCommand = `set -o pipefail; command find -L . -mindepth 1 \( -path '*/\.*' -o -fstype 'sysfs' -o -fstype 'devfs' -o -fstype 'devtmpfs' -o -fstype 'proc' \) -prune -o -type f -print -o -type l -print 2> /dev/null | cut -b3-`
|
|
} else if os.Getenv("TERM") == "cygwin" {
|
|
defaultCommand = `sh -c "command find -L . -mindepth 1 -path '*/\.*' -prune -o -type f -print -o -type l -print 2> /dev/null | cut -b3-"`
|
|
} else {
|
|
defaultCommand = `dir /s/b`
|
|
}
|
|
}
|
|
|
|
// fzf events
|
|
const (
|
|
EvtReadNew util.EventType = iota
|
|
EvtReadFin
|
|
EvtSearchNew
|
|
EvtSearchProgress
|
|
EvtSearchFin
|
|
EvtHeader
|
|
EvtReady
|
|
)
|
|
|
|
const (
|
|
exitOk = 0
|
|
exitNoMatch = 1
|
|
exitError = 2
|
|
exitInterrupt = 130
|
|
)
|