mirror of
https://github.com/junegunn/fzf.git
synced 2025-08-14 19:55:49 -07:00
Add backward-delete-char/eof action (#1891)
'backward-delete-char/eof' will either abort if query is empty or delete one character backwards.
This commit is contained in:
@@ -187,6 +187,7 @@ const (
|
||||
actAcceptNonEmpty
|
||||
actBackwardChar
|
||||
actBackwardDeleteChar
|
||||
actBackwardDeleteCharEOF
|
||||
actBackwardWord
|
||||
actCancel
|
||||
actClearScreen
|
||||
@@ -1846,6 +1847,13 @@ func (t *Terminal) Loop() {
|
||||
t.input = []rune{}
|
||||
t.cx = 0
|
||||
}
|
||||
case actBackwardDeleteCharEOF:
|
||||
if len(t.input) == 0 {
|
||||
req(reqQuit)
|
||||
} else if t.cx > 0 {
|
||||
t.input = append(t.input[:t.cx-1], t.input[t.cx:]...)
|
||||
t.cx--
|
||||
}
|
||||
case actForwardChar:
|
||||
if t.cx < len(t.input) {
|
||||
t.cx++
|
||||
|
Reference in New Issue
Block a user