mirror of
https://github.com/Llewellynvdm/fzf.git
synced 2025-02-03 04:28:36 +00:00
Add --phony option for disabling search
With --phony, fzf becomes a simply selector interface without its own search functionality. The query string is only used for building the command for preview or execute action. Close #1723
This commit is contained in:
parent
dceb5d09cd
commit
11962dabba
10
src/core.go
10
src/core.go
@ -227,6 +227,12 @@ func Run(opts *Options, revision string) {
|
|||||||
for {
|
for {
|
||||||
delay := true
|
delay := true
|
||||||
ticks++
|
ticks++
|
||||||
|
input := func() []rune {
|
||||||
|
if opts.Phony {
|
||||||
|
return []rune{}
|
||||||
|
}
|
||||||
|
return []rune(terminal.Input())
|
||||||
|
}
|
||||||
eventBox.Wait(func(events *util.Events) {
|
eventBox.Wait(func(events *util.Events) {
|
||||||
if _, fin := (*events)[EvtReadFin]; fin {
|
if _, fin := (*events)[EvtReadFin]; fin {
|
||||||
delete(*events, EvtReadNew)
|
delete(*events, EvtReadNew)
|
||||||
@ -241,7 +247,7 @@ func Run(opts *Options, revision string) {
|
|||||||
if opts.Sync {
|
if opts.Sync {
|
||||||
terminal.UpdateList(PassMerger(&snapshot, opts.Tac))
|
terminal.UpdateList(PassMerger(&snapshot, opts.Tac))
|
||||||
}
|
}
|
||||||
matcher.Reset(snapshot, terminal.Input(), false, !reading, sort)
|
matcher.Reset(snapshot, input(), false, !reading, sort)
|
||||||
|
|
||||||
case EvtSearchNew:
|
case EvtSearchNew:
|
||||||
switch val := value.(type) {
|
switch val := value.(type) {
|
||||||
@ -249,7 +255,7 @@ func Run(opts *Options, revision string) {
|
|||||||
sort = val
|
sort = val
|
||||||
}
|
}
|
||||||
snapshot, _ := chunkList.Snapshot()
|
snapshot, _ := chunkList.Snapshot()
|
||||||
matcher.Reset(snapshot, terminal.Input(), true, !reading, sort)
|
matcher.Reset(snapshot, input(), true, !reading, sort)
|
||||||
delay = false
|
delay = false
|
||||||
|
|
||||||
case EvtSearchProgress:
|
case EvtSearchProgress:
|
||||||
|
@ -33,6 +33,7 @@ const usage = `usage: fzf [options]
|
|||||||
-d, --delimiter=STR Field delimiter regex (default: AWK-style)
|
-d, --delimiter=STR Field delimiter regex (default: AWK-style)
|
||||||
+s, --no-sort Do not sort the result
|
+s, --no-sort Do not sort the result
|
||||||
--tac Reverse the order of the input
|
--tac Reverse the order of the input
|
||||||
|
--phony Do not perform search
|
||||||
--tiebreak=CRI[,..] Comma-separated list of sort criteria to apply
|
--tiebreak=CRI[,..] Comma-separated list of sort criteria to apply
|
||||||
when the scores are tied [length|begin|end|index]
|
when the scores are tied [length|begin|end|index]
|
||||||
(default: length)
|
(default: length)
|
||||||
@ -154,6 +155,7 @@ type Options struct {
|
|||||||
Fuzzy bool
|
Fuzzy bool
|
||||||
FuzzyAlgo algo.Algo
|
FuzzyAlgo algo.Algo
|
||||||
Extended bool
|
Extended bool
|
||||||
|
Phony bool
|
||||||
Case Case
|
Case Case
|
||||||
Normalize bool
|
Normalize bool
|
||||||
Nth []Range
|
Nth []Range
|
||||||
@ -207,6 +209,7 @@ func defaultOptions() *Options {
|
|||||||
Fuzzy: true,
|
Fuzzy: true,
|
||||||
FuzzyAlgo: algo.FuzzyMatchV2,
|
FuzzyAlgo: algo.FuzzyMatchV2,
|
||||||
Extended: true,
|
Extended: true,
|
||||||
|
Phony: false,
|
||||||
Case: CaseSmart,
|
Case: CaseSmart,
|
||||||
Normalize: true,
|
Normalize: true,
|
||||||
Nth: make([]Range, 0),
|
Nth: make([]Range, 0),
|
||||||
@ -1014,6 +1017,10 @@ func parseOptions(opts *Options, allArgs []string) {
|
|||||||
}
|
}
|
||||||
case "--no-expect":
|
case "--no-expect":
|
||||||
opts.Expect = make(map[int]string)
|
opts.Expect = make(map[int]string)
|
||||||
|
case "--no-phony":
|
||||||
|
opts.Phony = false
|
||||||
|
case "--phony":
|
||||||
|
opts.Phony = true
|
||||||
case "--tiebreak":
|
case "--tiebreak":
|
||||||
opts.Criteria = parseTiebreak(nextString(allArgs, &i, "sort criterion required"))
|
opts.Criteria = parseTiebreak(nextString(allArgs, &i, "sort criterion required"))
|
||||||
case "--bind":
|
case "--bind":
|
||||||
|
Loading…
x
Reference in New Issue
Block a user