[vim] Fix screen offset of relatively positioned popup window

Fix #2461
This commit is contained in:
Junegunn Choi 2021-04-28 10:17:46 +09:00
parent 8b0e1f941a
commit 6e3a2fe0bf
No known key found for this signature in database
GPG Key ID: 254BC280FEF9C627
1 changed files with 4 additions and 4 deletions

View File

@ -978,13 +978,13 @@ function! s:popup(opts) abort
" Use current window size for positioning relatively positioned popups
let columns = relative ? winwidth(0) : &columns
let lines = relative ? winheight(0) : &lines
let lines = relative ? winheight(0) : (&lines - has('nvim'))
" Size and position
let width = min([max([8, a:opts.width > 1 ? a:opts.width : float2nr(columns * a:opts.width)]), columns])
let height = min([max([4, a:opts.height > 1 ? a:opts.height : float2nr(lines * a:opts.height)]), lines - has('nvim')])
let row = float2nr(yoffset * (lines - height)) + (relative ? win_screenpos(0)[0] : 0)
let col = float2nr(xoffset * (columns - width)) + (relative ? win_screenpos(0)[1] : 0)
let height = min([max([4, a:opts.height > 1 ? a:opts.height : float2nr(lines * a:opts.height)]), lines])
let row = float2nr(yoffset * (lines - height)) + (relative ? win_screenpos(0)[0] - 1 : 0)
let col = float2nr(xoffset * (columns - width)) + (relative ? win_screenpos(0)[1] - 1 : 0)
" Managing the differences
let row = min([max([0, row]), &lines - has('nvim') - height])