mirror of
https://github.com/junegunn/fzf.git
synced 2025-08-15 04:05:48 -07:00
Add toggle-track action
This commit is contained in:
11
CHANGELOG.md
11
CHANGELOG.md
@@ -3,6 +3,17 @@ CHANGELOG
|
|||||||
|
|
||||||
0.39.1
|
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`
|
- Fixed `--track` behavior when used with `--tac`
|
||||||
- However, using `--track` with `--tac` is not recommended. The resulting
|
- However, using `--track` with `--tac` is not recommended. The resulting
|
||||||
behavior can be very confusing.
|
behavior can be very confusing.
|
||||||
|
@@ -337,6 +337,7 @@ const (
|
|||||||
actToggleUp
|
actToggleUp
|
||||||
actToggleIn
|
actToggleIn
|
||||||
actToggleOut
|
actToggleOut
|
||||||
|
actToggleTrack
|
||||||
actDown
|
actDown
|
||||||
actUp
|
actUp
|
||||||
actPageUp
|
actPageUp
|
||||||
@@ -1464,6 +1465,9 @@ func (t *Terminal) printInfo() {
|
|||||||
output += " -S"
|
output += " -S"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if t.track {
|
||||||
|
output += " +T"
|
||||||
|
}
|
||||||
if t.multi > 0 {
|
if t.multi > 0 {
|
||||||
if t.multi == maxMulti {
|
if t.multi == maxMulti {
|
||||||
output += fmt.Sprintf(" (%d)", len(t.selected))
|
output += fmt.Sprintf(" (%d)", len(t.selected))
|
||||||
@@ -3274,6 +3278,9 @@ func (t *Terminal) Loop() {
|
|||||||
t.paused = !t.paused
|
t.paused = !t.paused
|
||||||
changed = !t.paused
|
changed = !t.paused
|
||||||
req(reqPrompt)
|
req(reqPrompt)
|
||||||
|
case actToggleTrack:
|
||||||
|
t.track = !t.track
|
||||||
|
req(reqInfo)
|
||||||
case actEnableSearch:
|
case actEnableSearch:
|
||||||
t.paused = false
|
t.paused = false
|
||||||
changed = true
|
changed = true
|
||||||
|
@@ -2681,7 +2681,7 @@ class TestGoFZF < TestBase
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_track
|
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|
|
tmux.until do |lines|
|
||||||
assert_equal 1, lines.match_count
|
assert_equal 1, lines.match_count
|
||||||
assert_includes lines, '> 555'
|
assert_includes lines, '> 555'
|
||||||
@@ -2701,6 +2701,35 @@ class TestGoFZF < TestBase
|
|||||||
assert_equal 1000, lines.match_count
|
assert_equal 1000, lines.match_count
|
||||||
assert_equal '> 555', lines[index]
|
assert_equal '> 555', lines[index]
|
||||||
end
|
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
|
end
|
||||||
|
|
||||||
def test_one
|
def test_one
|
||||||
|
Reference in New Issue
Block a user