From c20954f020a16d6c013b59a894dead4cbfb52a83 Mon Sep 17 00:00:00 2001 From: Junegunn Choi Date: Fri, 1 Dec 2017 13:08:55 +0900 Subject: Add replace-query action replace-query action replaces the query string with the current selection. If the selection is too long, it will be truncated. If the line contains meta-characters of fzf search syntax, it is possible that the line is no longer included in the updated result. e.g. echo '!hello' | fzf --bind ctrl-v:replace-query Close #1137 --- src/options.go | 2 ++ src/terminal.go | 6 ++++++ 2 files changed, 8 insertions(+) (limited to 'src') diff --git a/src/options.go b/src/options.go index 11a5021b..730c1167 100644 --- a/src/options.go +++ b/src/options.go @@ -664,6 +664,8 @@ func parseKeymap(keymap map[int][]action, str string) { appendAction(actAccept) case "print-query": appendAction(actPrintQuery) + case "replace-query": + appendAction(actReplaceQuery) case "backward-char": appendAction(actBackwardChar) case "backward-delete-char": diff --git a/src/terminal.go b/src/terminal.go index 2da2e4c6..82f0ac9f 100644 --- a/src/terminal.go +++ b/src/terminal.go @@ -203,6 +203,7 @@ const ( actJump actJumpAccept actPrintQuery + actReplaceQuery actToggleSort actTogglePreview actTogglePreviewWrap @@ -1568,6 +1569,11 @@ func (t *Terminal) Loop() { } case actPrintQuery: req(reqPrintQuery) + case actReplaceQuery: + if t.cy < t.merger.Length() { + t.input = t.merger.Get(t.cy).item.text.ToRunes() + t.cx = len(t.input) + } case actAbort: req(reqQuit) case actDeleteChar: -- cgit v1.2.3