From 3e9efd1401404da8afdcf9757ac9996f5c48290f Mon Sep 17 00:00:00 2001 From: Junegunn Choi Date: Sat, 3 Jun 2023 09:03:04 +0900 Subject: [PATCH] [vim] Only prepend --border option in $FZF_DEFAULT_OPTS Fix #3318 --- plugin/fzf.vim | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) 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