Skip to content

Commit

Permalink
Remove leading underscores from fzf_search_vars_cmd
Browse files Browse the repository at this point in the history
Since fzf_search_vars_cmd is meant to be exposed and used by the user (for users who customize their key bindings), it should not start with __, which is conventionally used to signal that the entity should be off limits to the user.
  • Loading branch information
PatrickF1 committed Feb 16, 2021
1 parent bada3e6 commit f14a1d3
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions conf.d/fzf.fish
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
# them before even executing __fzf_search_shell_variables. We use psub to store the
# variables' info in temporary files and pass in the filenames as arguments.
# This variable is intentionally global so that it can be referenced by custom key bindings and tests
set --global __fzf_search_vars_cmd '__fzf_search_shell_variables (set --show | psub) (set --names | psub)'
set --global fzf_search_vars_cmd '__fzf_search_shell_variables (set --show | psub) (set --names | psub)'

# Set up the default, mnemonic key bindings unless the user has chosen to customize them
if not set --query fzf_fish_custom_keybindings
# \cf is Ctrl+f
bind \cf '__fzf_search_current_dir'
bind \cr '__fzf_search_history'
bind \cv $__fzf_search_vars_cmd
bind \cv $fzf_search_vars_cmd
# The following two key binding use Alt as an additional modifier key to avoid conflicts
bind \e\cl '__fzf_search_git_log'
bind \e\cs '__fzf_search_git_status'
Expand All @@ -18,7 +18,7 @@ if not set --query fzf_fish_custom_keybindings
if test "$fish_key_bindings" = 'fish_vi_key_bindings'
bind --mode insert \cf '__fzf_search_current_dir'
bind --mode insert \cr '__fzf_search_history'
bind --mode insert \cv $__fzf_search_vars_cmd
bind --mode insert \cv $fzf_search_vars_cmd
bind --mode insert \e\cl '__fzf_search_git_log'
bind --mode insert \e\cs '__fzf_search_git_status'
end
Expand Down
2 changes: 1 addition & 1 deletion tests/search_shell_variables/$_in_curr_token.fish
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ mock commandline --current-token "echo \\\$variable"
mock commandline "--current-token --replace" "echo \$argv" # instead of updating commandline with the result, just output it
mock fzf \* "echo selection"

set actual (eval $__fzf_search_vars_cmd)
set actual (eval $fzf_search_vars_cmd)
@test "doesn't overwrite \$ when replacing current token with selected variable" $actual = "\$selection"
2 changes: 1 addition & 1 deletion tests/search_shell_variables/local_var.fish
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ set --local a_local_variable
set --export --append FZF_DEFAULT_OPTS "--filter=a_local_variable"
mock commandline "--current-token --replace" "echo \$argv" # instead of updating commandline with the result, just output it
mock commandline \* "" # mock all other commandline executions to do nothing
set actual (eval $__fzf_search_vars_cmd)
set actual (eval $fzf_search_vars_cmd)
@test "can find a local variable" $actual = a_local_variable

0 comments on commit f14a1d3

Please sign in to comment.