mirror of
https://github.com/Llewellynvdm/fzf.git
synced 2024-12-23 03:19:01 +00:00
Add toggle-track action
This commit is contained in:
parent
7c6f5dba63
commit
0c61d81713
11
CHANGELOG.md
11
CHANGELOG.md
@ -3,6 +3,17 @@ CHANGELOG
|
||||
|
||||
0.39.1
|
||||
------
|
||||
- Added `toggle-track` action. Temporarily enabling tracking is useful when
|
||||
you want to see the surrounding items by deleting the query string.
|
||||
```sh
|
||||
export FZF_CTRL_R_OPTS="
|
||||
--preview 'echo {}' --preview-window up:3:hidden:wrap
|
||||
--bind 'ctrl-/:toggle-preview'
|
||||
--bind 'ctrl-t:toggle-track'
|
||||
--bind 'ctrl-y:execute-silent(echo -n {2..} | pbcopy)+abort'
|
||||
--color header:italic
|
||||
--header 'Press CTRL-Y to copy command into clipboard'"
|
||||
```
|
||||
- Fixed `--track` behavior when used with `--tac`
|
||||
- However, using `--track` with `--tac` is not recommended. The resulting
|
||||
behavior can be very confusing.
|
||||
|
@ -337,6 +337,7 @@ const (
|
||||
actToggleUp
|
||||
actToggleIn
|
||||
actToggleOut
|
||||
actToggleTrack
|
||||
actDown
|
||||
actUp
|
||||
actPageUp
|
||||
@ -1464,6 +1465,9 @@ func (t *Terminal) printInfo() {
|
||||
output += " -S"
|
||||
}
|
||||
}
|
||||
if t.track {
|
||||
output += " +T"
|
||||
}
|
||||
if t.multi > 0 {
|
||||
if t.multi == maxMulti {
|
||||
output += fmt.Sprintf(" (%d)", len(t.selected))
|
||||
@ -3274,6 +3278,9 @@ func (t *Terminal) Loop() {
|
||||
t.paused = !t.paused
|
||||
changed = !t.paused
|
||||
req(reqPrompt)
|
||||
case actToggleTrack:
|
||||
t.track = !t.track
|
||||
req(reqInfo)
|
||||
case actEnableSearch:
|
||||
t.paused = false
|
||||
changed = true
|
||||
|
@ -2681,7 +2681,7 @@ class TestGoFZF < TestBase
|
||||
end
|
||||
|
||||
def test_track
|
||||
tmux.send_keys "seq 1000 | #{FZF} --query 555 --track", :Enter
|
||||
tmux.send_keys "seq 1000 | #{FZF} --query 555 --track --bind t:toggle-track", :Enter
|
||||
tmux.until do |lines|
|
||||
assert_equal 1, lines.match_count
|
||||
assert_includes lines, '> 555'
|
||||
@ -2701,6 +2701,35 @@ class TestGoFZF < TestBase
|
||||
assert_equal 1000, lines.match_count
|
||||
assert_equal '> 555', lines[index]
|
||||
end
|
||||
tmux.send_keys '555'
|
||||
tmux.until do |lines|
|
||||
assert_equal 1, lines.match_count
|
||||
assert_includes lines, '> 555'
|
||||
assert_includes lines[-2], '+T'
|
||||
end
|
||||
tmux.send_keys 't'
|
||||
tmux.until do |lines|
|
||||
refute_includes lines[-2], '+T'
|
||||
end
|
||||
tmux.send_keys :BSpace
|
||||
tmux.until do |lines|
|
||||
assert_equal 28, lines.match_count
|
||||
assert_includes lines, '> 55'
|
||||
end
|
||||
tmux.send_keys :BSpace
|
||||
tmux.until do |lines|
|
||||
assert_equal 271, lines.match_count
|
||||
assert_includes lines, '> 5'
|
||||
end
|
||||
tmux.send_keys 't'
|
||||
tmux.until do |lines|
|
||||
assert_includes lines[-2], '+T'
|
||||
end
|
||||
tmux.send_keys :BSpace
|
||||
tmux.until do |lines|
|
||||
assert_equal 1000, lines.match_count
|
||||
assert_includes lines, '> 5'
|
||||
end
|
||||
end
|
||||
|
||||
def test_one
|
||||
|
Loading…
Reference in New Issue
Block a user