diff options
| author | Junegunn Choi <junegunn.c@gmail.com> | 2020-02-06 10:38:37 +0900 |
|---|---|---|
| committer | Junegunn Choi <junegunn.c@gmail.com> | 2020-02-06 10:40:57 +0900 |
| commit | a859aa72ee0ab6e7ae948752906483e468a501ee (patch) | |
| tree | 093eaf2b79f26138d31bb968cbe482997609556b /plugin | |
| parent | 0896036266dc951ac03c451f1097171a996eb412 (diff) | |
| download | fzf-a859aa72ee0ab6e7ae948752906483e468a501ee.tar.gz | |
[vim] Add support for xoffset and yoffset options for popup
Close https://github.com/junegunn/fzf.vim/issues/942
Diffstat (limited to 'plugin')
| -rw-r--r-- | plugin/fzf.vim | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/plugin/fzf.vim b/plugin/fzf.vim index e4c6e106..5c93f5aa 100644 --- a/plugin/fzf.vim +++ b/plugin/fzf.vim @@ -843,10 +843,16 @@ endif function! s:popup(opts) abort " Size and position - let width = float2nr(&columns * a:opts.width) - let height = float2nr(&lines * a:opts.height) - let row = float2nr((&lines - height) / 2) - let col = float2nr((&columns - width) / 2) + let width = min([max([0, float2nr(&columns * a:opts.width)]), &columns]) + let height = min([max([0, float2nr(&lines * a:opts.height)]), &lines - has('nvim')]) + let row = float2nr(get(a:opts, 'yoffset', 0.5) * (&lines - height)) + let col = float2nr(get(a:opts, 'xoffset', 0.5) * (&columns - width)) + + " Managing the differences + let row = min([max([0, row]), &lines - has('nvim') - height]) + let col = min([max([0, col]), &columns - width]) + let row += !has('nvim') + let col += !has('nvim') " Border let edges = get(a:opts, 'rounded', 1) ? ['╭', '╮', '╰', '╯'] : ['┌', '┐', '└', '┘'] |
