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:
Junegunn Choi
2022-12-27 01:01:06 +09:00
parent d42e708d31
commit 12af069dca
5 changed files with 41 additions and 3 deletions

View File

@@ -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 {