mirror of
https://github.com/Llewellynvdm/fzf.git
synced 2024-06-03 07:50:49 +00:00
Add 'start' event that is triggered once when fzf finder starts
Close #1622
This commit is contained in:
parent
170fc517d0
commit
168829b555
|
@ -1,6 +1,15 @@
|
||||||
CHANGELOG
|
CHANGELOG
|
||||||
=========
|
=========
|
||||||
|
|
||||||
|
0.35.0
|
||||||
|
------
|
||||||
|
- Added `start` event that is triggered only once when fzf finder starts.
|
||||||
|
Since fzf consumes the input stream asynchronously, the input list is not
|
||||||
|
available unless you use `--sync`.
|
||||||
|
```sh
|
||||||
|
seq 100 | fzf --multi --sync --bind 'start:last+select-all+preview(echo welcome)'
|
||||||
|
```
|
||||||
|
|
||||||
0.34.0
|
0.34.0
|
||||||
------
|
------
|
||||||
- Added support for adaptive `--height`. If the `--height` value is prefixed
|
- Added support for adaptive `--height`. If the `--height` value is prefixed
|
||||||
|
|
|
@ -21,7 +21,7 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
THE SOFTWARE.
|
THE SOFTWARE.
|
||||||
..
|
..
|
||||||
.TH fzf 1 "Sep 2022" "fzf 0.34.0" "fzf - a command-line fuzzy finder"
|
.TH fzf 1 "Oct 2022" "fzf 0.35.0" "fzf - a command-line fuzzy finder"
|
||||||
|
|
||||||
.SH NAME
|
.SH NAME
|
||||||
fzf - a command-line fuzzy finder
|
fzf - a command-line fuzzy finder
|
||||||
|
@ -811,6 +811,15 @@ e.g.
|
||||||
or any single character
|
or any single character
|
||||||
|
|
||||||
.SS AVAILABLE EVENTS:
|
.SS AVAILABLE EVENTS:
|
||||||
|
\fIstart\fR
|
||||||
|
.RS
|
||||||
|
Triggered only once when fzf finder starts. Since fzf consumes the input stream
|
||||||
|
asynchronously, the input list is not available unless you use \fI--sync\fR.
|
||||||
|
|
||||||
|
e.g.
|
||||||
|
\fB# Move cursor to the last item and select all items
|
||||||
|
seq 1000 | fzf --multi --sync --bind start:last+select-all\fR
|
||||||
|
.RE
|
||||||
\fIchange\fR
|
\fIchange\fR
|
||||||
.RS
|
.RS
|
||||||
Triggered whenever the query string is changed
|
Triggered whenever the query string is changed
|
||||||
|
|
|
@ -543,6 +543,8 @@ func parseKeyChords(str string, message string) map[tui.Event]string {
|
||||||
add(tui.Change)
|
add(tui.Change)
|
||||||
case "backward-eof":
|
case "backward-eof":
|
||||||
add(tui.BackwardEOF)
|
add(tui.BackwardEOF)
|
||||||
|
case "start":
|
||||||
|
add(tui.Start)
|
||||||
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":
|
||||||
|
|
|
@ -2362,13 +2362,21 @@ func (t *Terminal) Loop() {
|
||||||
}()
|
}()
|
||||||
|
|
||||||
looping := true
|
looping := true
|
||||||
|
_, startEvent := t.keymap[tui.Start.AsEvent()]
|
||||||
|
|
||||||
for looping {
|
for looping {
|
||||||
var newCommand *string
|
var newCommand *string
|
||||||
changed := false
|
changed := false
|
||||||
beof := false
|
beof := false
|
||||||
queryChanged := false
|
queryChanged := false
|
||||||
|
|
||||||
event := t.tui.GetChar()
|
var event tui.Event
|
||||||
|
if startEvent {
|
||||||
|
event = tui.Start.AsEvent()
|
||||||
|
startEvent = false
|
||||||
|
} else {
|
||||||
|
event = t.tui.GetChar()
|
||||||
|
}
|
||||||
|
|
||||||
t.mutex.Lock()
|
t.mutex.Lock()
|
||||||
previousInput := t.input
|
previousInput := t.input
|
||||||
|
|
|
@ -90,6 +90,7 @@ const (
|
||||||
|
|
||||||
Change
|
Change
|
||||||
BackwardEOF
|
BackwardEOF
|
||||||
|
Start
|
||||||
|
|
||||||
AltBS
|
AltBS
|
||||||
|
|
||||||
|
|
|
@ -2332,6 +2332,14 @@ class TestGoFZF < TestBase
|
||||||
OUTPUT
|
OUTPUT
|
||||||
tmux.until { assert_block(expected, _1) }
|
tmux.until { assert_block(expected, _1) }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_start_event
|
||||||
|
tmux.send_keys 'seq 100 | fzf --multi --sync --preview-window border-none --bind "start:select-all+last+preview(echo welcome)"', :Enter
|
||||||
|
tmux.until do |lines|
|
||||||
|
assert_match(/>100.*welcome/, lines[0])
|
||||||
|
assert_includes(lines[-2], '100/100 (100)')
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
module TestShell
|
module TestShell
|
||||||
|
|
Loading…
Reference in New Issue
Block a user