Skip to content
Myr

Make --expect additive

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Similarly to --bind or --color. --expect used to replace the previously specified keys, and fzf#wrap({'options': '--expect=f1'}) wouldn't work as expected. It forced us to come up with some ugly hacks like the following: https://github.com/junegunn/fzf.vim/blob/13b27c45c8bdf6c3a41376bb83e4895edadf8c7e/autoload/fzf/vim.vim#L1086

authored by Junegunn Choi · committed by Junegunn Choi · parent 6b4805c · Browse files · 3 files+17 added−4 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Trailers

  • https: //github.com/junegunn/fzf.vim/blob/13b27c45c8bdf6c3a41376bb83e4895edadf8c7e/autoload/fzf/vim.vim#L1086

Diff stats

3 files+17 added−4 removed

  • other:+17 added−4 removed

3 files+17 added−4 removed

modified:man/man1/fzf.1+4 added-2 removed
329 unmodified lines
330Comma-separated list of keys that can be used to complete fzf in addition to331the default enter key. When this option is set, fzf will print the name of the332key pressed as the first line of its output (or as the second line if333\fB--print-query\fR is also used). The line will be empty if fzf is completed334with the default enter key.334with the default enter key. If \fB--expect\fR option is specified multiple335times, fzf will expect the union of the keys. \fB--no-expect\fR will clear the336list.337338.RS337e.g. \fBfzf --expect=ctrl-v,ctrl-t,alt-s,f1,f2,~,@\fR339e.g. \fBfzf --expect=ctrl-v,ctrl-t,alt-s --expect=f1,f2,~,@\fR340.RE341.TP342.B "--read0"343Read input delimited by ASCII NUL characters instead of newline characters
253 unmodified lines
modified:src/options_test.go+7 added
412 unmodified lines
413 opts.Preview.size.size == 15+2) {414 t.Error(opts.Preview)415 }416}417418func TestAdditiveExpect(t *testing.T) {419 opts := optsFor("--expect=a", "--expect", "b", "--expect=c")420 if len(opts.Expect) != 3 {421 t.Error(opts.Expect)422 }423}
modified:src/options.go+6 added-2 removed
960 unmodified lines
961 opts.Normalize = true962 case "--algo":963 opts.FuzzyAlgo = parseAlgo(nextString(allArgs, &i, "algorithm required (v1|v2)"))964 case "--expect":965 opts.Expect = parseKeyChords(nextString(allArgs, &i, "key names required"), "key names required")965 for k, v := range parseKeyChords(nextString(allArgs, &i, "key names required"), "key names required") {966 opts.Expect[k] = v967 }968 case "--no-expect":969 opts.Expect = make(map[int]string)970 case "--tiebreak":971 opts.Criteria = parseTiebreak(nextString(allArgs, &i, "sort criterion required"))
169 unmodified lines
1141 opts.MinHeight = atoi(value)1142 } else if match, value := optString(arg, "--toggle-sort="); match {1143 parseToggleSort(opts.Keymap, value)1144 } else if match, value := optString(arg, "--expect="); match {1143 opts.Expect = parseKeyChords(value, "key names required")1145 for k, v := range parseKeyChords(value, "key names required") {1146 opts.Expect[k] = v1147 }1148 } else if match, value := optString(arg, "--tiebreak="); match {1149 opts.Criteria = parseTiebreak(value)1150 } else if match, value := optString(arg, "--color="); match {1151 opts.Theme = parseTheme(opts.Theme, value)
104 unmodified lines