mirror of
https://github.com/junegunn/fzf.git
synced 2025-08-14 19:55:49 -07:00
@@ -3,6 +3,11 @@ CHANGELOG
|
|||||||
|
|
||||||
0.39.0
|
0.39.0
|
||||||
------
|
------
|
||||||
|
- Added `one` event that is triggered when there's only one match
|
||||||
|
```sh
|
||||||
|
# Automatically select the only match
|
||||||
|
seq 10 | fzf --bind one:accept
|
||||||
|
```
|
||||||
- Added `--track` option that makes fzf track the current selection when the
|
- Added `--track` option that makes fzf track the current selection when the
|
||||||
result list is updated. This can be useful when browsing logs using fzf with
|
result list is updated. This can be useful when browsing logs using fzf with
|
||||||
sorting disabled.
|
sorting disabled.
|
||||||
|
@@ -993,6 +993,17 @@ e.g.
|
|||||||
# Beware not to introduce an infinite loop
|
# Beware not to introduce an infinite loop
|
||||||
seq 10 | fzf --bind 'focus:up' --cycle\fR
|
seq 10 | fzf --bind 'focus:up' --cycle\fR
|
||||||
.RE
|
.RE
|
||||||
|
\fIone\fR
|
||||||
|
.RS
|
||||||
|
Triggered when there's only one match. \fBone:accept\fR binding is comparable
|
||||||
|
to \fB--select-1\fR option, but the difference is that \fB--select-1\fR is only
|
||||||
|
effective before the interactive finder starts but \fBone\fR event is triggered
|
||||||
|
by the interactive finder.
|
||||||
|
|
||||||
|
e.g.
|
||||||
|
\fB# Automatically select the only match
|
||||||
|
seq 10 | fzf --bind one:accept\fR
|
||||||
|
.RE
|
||||||
|
|
||||||
\fIbackward-eof\fR
|
\fIbackward-eof\fR
|
||||||
.RS
|
.RS
|
||||||
|
@@ -622,6 +622,8 @@ func parseKeyChordsImpl(str string, message string, exit func(string)) map[tui.E
|
|||||||
add(tui.Load)
|
add(tui.Load)
|
||||||
case "focus":
|
case "focus":
|
||||||
add(tui.Focus)
|
add(tui.Focus)
|
||||||
|
case "one":
|
||||||
|
add(tui.One)
|
||||||
case "alt-enter", "alt-return":
|
case "alt-enter", "alt-return":
|
||||||
chords[tui.CtrlAltKey('m')] = key
|
chords[tui.CtrlAltKey('m')] = key
|
||||||
case "alt-space":
|
case "alt-space":
|
||||||
|
@@ -932,6 +932,12 @@ func (t *Terminal) UpdateList(merger *Merger, reset bool) {
|
|||||||
t.cy = count - util.Min(count, t.maxItems()) + pos
|
t.cy = count - util.Min(count, t.maxItems()) + pos
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if !t.reading && t.merger.Length() == 1 {
|
||||||
|
one := tui.One.AsEvent()
|
||||||
|
if _, prs := t.keymap[one]; prs {
|
||||||
|
t.eventChan <- one
|
||||||
|
}
|
||||||
|
}
|
||||||
t.mutex.Unlock()
|
t.mutex.Unlock()
|
||||||
t.reqBox.Set(reqInfo, nil)
|
t.reqBox.Set(reqInfo, nil)
|
||||||
t.reqBox.Set(reqList, nil)
|
t.reqBox.Set(reqList, nil)
|
||||||
|
@@ -93,6 +93,7 @@ const (
|
|||||||
Start
|
Start
|
||||||
Load
|
Load
|
||||||
Focus
|
Focus
|
||||||
|
One
|
||||||
|
|
||||||
AltBS
|
AltBS
|
||||||
|
|
||||||
|
@@ -2702,6 +2702,20 @@ class TestGoFZF < TestBase
|
|||||||
assert_equal '> 555', lines[index]
|
assert_equal '> 555', lines[index]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_one
|
||||||
|
tmux.send_keys "seq 10 | #{FZF} --bind 'one:preview:echo {} is the only match'", :Enter
|
||||||
|
tmux.send_keys '1'
|
||||||
|
tmux.until do |lines|
|
||||||
|
assert_equal 2, lines.match_count
|
||||||
|
refute lines.any? { _1.include?('only match') }
|
||||||
|
end
|
||||||
|
tmux.send_keys '0'
|
||||||
|
tmux.until do |lines|
|
||||||
|
assert_equal 1, lines.match_count
|
||||||
|
assert lines.any? { _1.include?('only match') }
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
module TestShell
|
module TestShell
|
||||||
|
Reference in New Issue
Block a user