[vim] Fix height calculation

Fix #1418

e.g.
  call fzf#run({'source': [1, 2, 3], 'down': '~50%', 'options': "--border --header $'1\n2'"})
This commit is contained in:
Junegunn Choi 2020-03-03 23:48:12 +09:00
parent dd49e41c42
commit 242c0db26b
No known key found for this signature in database
GPG Key ID: 254BC280FEF9C627

View File

@ -642,9 +642,11 @@ function! s:calc_size(max, val, dict)
endif
let opts = $FZF_DEFAULT_OPTS.' '.s:evaluate_opts(get(a:dict, 'options', ''))
let margin = stridx(opts, '--inline-info') > stridx(opts, '--no-inline-info') ? 1 : 2
let margin = match(opts, '--inline-info\|--info[^-]\{-}inline') > match(opts, '--no-inline-info\|--info[^-]\{-}\(default\|hidden\)') ? 1 : 2
let margin += stridx(opts, '--border') > stridx(opts, '--no-border') ? 2 : 0
let margin += stridx(opts, '--header') > stridx(opts, '--no-header')
if stridx(opts, '--header') > stridx(opts, '--no-header')
let margin += len(split(opts, "\n"))
endif
return srcsz >= 0 ? min([srcsz + margin, size]) : size
endfunction