From a859aa72ee0ab6e7ae948752906483e468a501ee Mon Sep 17 00:00:00 2001 From: Junegunn Choi Date: Thu, 6 Feb 2020 10:38:37 +0900 Subject: [vim] Add support for xoffset and yoffset options for popup Close https://github.com/junegunn/fzf.vim/issues/942 --- plugin/fzf.vim | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'plugin') 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) ? ['╭', '╮', '╰', '╯'] : ['┌', '┐', '└', '┘'] -- cgit v1.2.3