summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJunegunn Choi <junegunn.c@gmail.com>2023-06-03 09:03:04 +0900
committerJunegunn Choi <junegunn.c@gmail.com>2023-06-03 09:03:04 +0900
commit3e9efd1401404da8afdcf9757ac9996f5c48290f (patch)
tree30f1f26527d271c356adee620cec0befe80f9476
parent20340190b5bec56d742624421238c9f813e8eea5 (diff)
[vim] Only prepend --border option in $FZF_DEFAULT_OPTS
Fix #3318
-rw-r--r--plugin/fzf.vim26
1 files changed, 25 insertions, 1 deletions
diff --git a/plugin/fzf.vim b/plugin/fzf.vim
index f192ecbe..ac7e169e 100644
--- a/plugin/fzf.vim
+++ b/plugin/fzf.vim
@@ -456,6 +456,30 @@ function! s:writefile(...)
endif
endfunction
+function! s:extract_option(opts, name)
+ let opt = ''
+ let expect = 0
+ " There are a few cases where this function doesn't work as expected.
+ " Let's just assume such cases are extremely unlikely in real world.
+ " e.g. --query --border
+ for word in split(a:opts)
+ if expect && word !~ '^"\=-'
+ let opt = opt . ' ' . word
+ let expect = 0
+ elseif word == '--no-'.a:name
+ let opt = ''
+ elseif word =~ '^--'.a:name.'='
+ let opt = word
+ elseif word =~ '^--'.a:name.'$'
+ let opt = word
+ let expect = 1
+ elseif expect
+ let expect = 0
+ endif
+ endfor
+ return opt
+endfunction
+
function! fzf#run(...) abort
try
let [shell, shellslash, shellcmdflag, shellxquote] = s:use_sh()
@@ -512,7 +536,7 @@ try
let optstr .= ' --height='.height
endif
" Respect --border option given in $FZF_DEFAULT_OPTS and 'options'
- let optstr = join([s:border_opt(get(dict, 'window', 0)), $FZF_DEFAULT_OPTS, optstr])
+ let optstr = join([s:border_opt(get(dict, 'window', 0)), s:extract_option($FZF_DEFAULT_OPTS, 'border'), optstr])
let prev_default_command = $FZF_DEFAULT_COMMAND
if len(source_command)
let $FZF_DEFAULT_COMMAND = source_command