diff --git a/.vim/plugin/fuzzy-finders.vim b/.vim/plugin/fuzzy-finders.vim index 42e47c6..e84ea58 100644 --- a/.vim/plugin/fuzzy-finders.vim +++ b/.vim/plugin/fuzzy-finders.vim @@ -63,6 +63,10 @@ function! s:FuzzySnippets() abort let l:output = join(a:input[1:], "\n") + if len(l:output) == 0 + return + endif + if a:input[0] ==? 'ctrl-y' call setreg('"', l:output) diff --git a/bin/fuzzy-snippets b/bin/fuzzy-snippets index f921c31..484168d 100755 --- a/bin/fuzzy-snippets +++ b/bin/fuzzy-snippets @@ -140,6 +140,8 @@ if [ "$VIM_MODE" = 1 ]; then FZF_LABEL='ENTER: insert ╱ CTRL+Y: yank ╱ F1: help' fi +set +e + # CTRL+Z process suspension is suppressed as it doesn't work properly # (see ). FZF_OUTPUT=$(\ @@ -157,6 +159,20 @@ FZF_OUTPUT=$(\ --scheme='path' \ --with-nth='-1' \ ) +FZF_STATUS="$?" + +if [ "$FZF_STATUS" != 0 ]; then + # Allow this script to exit cleanly if fzf exits with a return code of + # 130, signalling that it was aborted or interrupted by the user. + if [ "$FZF_STATUS" = 130 ]; then + exit + else + exit $FZF_STATUS + fi +fi + +set -e + SELECTED_ACTION=$(echo "$FZF_OUTPUT" | head -1) SELECTED_FILE=$(echo "$FZF_OUTPUT" | tail -1)