mirror of
https://github.com/junegunn/fzf.git
synced 2025-08-09 00:22:02 -07:00
Add pos(...) action to move the cursor to the numeric position
# Put the cursor on the 10th item seq 100 | fzf --sync --bind 'start:pos(10)' # Put the cursor on the 10th to last item seq 100 | fzf --sync --bind 'start:pos(-10)' Close #3069 Close #395
This commit is contained in:
@@ -297,6 +297,7 @@ const (
|
||||
actUp
|
||||
actPageUp
|
||||
actPageDown
|
||||
actPosition
|
||||
actHalfPageUp
|
||||
actHalfPageDown
|
||||
actJump
|
||||
@@ -2837,6 +2838,16 @@ func (t *Terminal) Loop() {
|
||||
case actLast:
|
||||
t.vset(t.merger.Length() - 1)
|
||||
req(reqList)
|
||||
case actPosition:
|
||||
if n, e := strconv.Atoi(a.a); e == nil {
|
||||
if n > 0 {
|
||||
n--
|
||||
} else if n < 0 {
|
||||
n += t.merger.Length()
|
||||
}
|
||||
t.vset(n)
|
||||
req(reqList)
|
||||
}
|
||||
case actUnixLineDiscard:
|
||||
beof = len(t.input) == 0
|
||||
if t.cx > 0 {
|
||||
|
Reference in New Issue
Block a user