m/fzf
1
0
mirror of https://github.com/junegunn/fzf.git synced 2025-11-15 23:03:47 -05:00

Add backward-eof event for --bind

This commit is contained in:
Junegunn Choi
2020-06-07 23:07:03 +09:00
parent 06d63a862e
commit a7aa08ce07
5 changed files with 40 additions and 5 deletions

View File

@@ -1738,6 +1738,7 @@ func (t *Terminal) Loop() {
for looping {
var newCommand *string
changed := false
beof := false
queryChanged := false
event := t.tui.GetChar()
@@ -1881,6 +1882,7 @@ func (t *Terminal) Loop() {
t.cx++
}
case actBackwardDeleteChar:
beof = len(t.input) == 0
if t.cx > 0 {
t.input = append(t.input[:t.cx-1], t.input[t.cx:]...)
t.cx--
@@ -1973,16 +1975,19 @@ func (t *Terminal) Loop() {
t.vset(0)
req(reqList)
case actUnixLineDiscard:
beof = len(t.input) == 0
if t.cx > 0 {
t.yanked = copySlice(t.input[:t.cx])
t.input = t.input[t.cx:]
t.cx = 0
}
case actUnixWordRubout:
beof = len(t.input) == 0
if t.cx > 0 {
t.rubout("\\s\\S")
}
case actBackwardKillWord:
beof = len(t.input) == 0
if t.cx > 0 {
t.rubout(t.wordRubout)
}
@@ -2145,6 +2150,11 @@ func (t *Terminal) Loop() {
continue
}
}
if onEOFs, prs := t.keymap[tui.BackwardEOF]; beof && prs {
if !doActions(onEOFs, tui.BackwardEOF) {
continue
}
}
} else {
if mapkey == tui.Rune {
if idx := strings.IndexRune(t.jumpLabels, event.Char); idx >= 0 && idx < t.maxItems() && idx < t.merger.Length() {