diff options
| author | Junegunn Choi <junegunn.c@gmail.com> | 2017-12-01 13:08:55 +0900 |
|---|---|---|
| committer | Junegunn Choi <junegunn.c@gmail.com> | 2017-12-01 13:08:55 +0900 |
| commit | c20954f020a16d6c013b59a894dead4cbfb52a83 (patch) | |
| tree | 41ce3f363a8932526e9c4da17ba8754ba6bf9e0c /src | |
| parent | 1e8e1d3c9deaf3abdcf42ab5b63927b9eac4a98c (diff) | |
| download | fzf-c20954f020a16d6c013b59a894dead4cbfb52a83.tar.gz | |
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
Diffstat (limited to 'src')
| -rw-r--r-- | src/options.go | 2 | ||||
| -rw-r--r-- | src/terminal.go | 6 |
2 files changed, 8 insertions, 0 deletions
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: |
