diff options
author | Ronan Pigott <rpigott@berkeley.edu> | 2018-09-16 04:15:46 -0500 |
---|---|---|
committer | Justin M. Keyes <justinkz@gmail.com> | 2018-09-16 11:15:46 +0200 |
commit | 9ed46a77e6496e3a16c17b05ef4595393db6437b (patch) | |
tree | 1fbe6b299b67496e6019953bb9c08019a1098540 | |
parent | 3bce5207cf4649974f194b51ffe3e34e08d5184d (diff) | |
download | rneovim-9ed46a77e6496e3a16c17b05ef4595393db6437b.tar.gz rneovim-9ed46a77e6496e3a16c17b05ef4595393db6437b.tar.bz2 rneovim-9ed46a77e6496e3a16c17b05ef4595393db6437b.zip |
vim-patch:8.1.0355 Incorrect adjusting the popup menu (#8996)
Problem: Incorrect adjusting the popup menu for the preview window.
Solution: Compute position and height properl. (Ronan Pigott) Also show at
least ten items. (closes vim/vim#3414)
-rw-r--r-- | src/nvim/popupmnu.c | 12 | ||||
-rw-r--r-- | test/functional/ui/popupmenu_spec.lua | 50 |
2 files changed, 49 insertions, 13 deletions
diff --git a/src/nvim/popupmnu.c b/src/nvim/popupmnu.c index 4c51f5de5e..68c8967b91 100644 --- a/src/nvim/popupmnu.c +++ b/src/nvim/popupmnu.c @@ -201,9 +201,15 @@ void pum_display(pumitem_T *array, int size, int selected, bool array_changed) } // If there is a preview window above, avoid drawing over it. - if (pvwin != NULL && pum_row < above_row && pum_height > above_row) { - pum_row += above_row; - pum_height -= above_row; + // Do keep at least 10 entries. + if (pvwin != NULL && pum_row < above_row && pum_height > 10) { + if (row - above_row < 10) { + pum_row = row - 10; + pum_height = 10; + } else { + pum_row = above_row; + pum_height = row - above_row; + } } // Compute the width of the widest match and the widest extra. diff --git a/test/functional/ui/popupmenu_spec.lua b/test/functional/ui/popupmenu_spec.lua index 2689e004c0..606c7c1e26 100644 --- a/test/functional/ui/popupmenu_spec.lua +++ b/test/functional/ui/popupmenu_spec.lua @@ -170,29 +170,59 @@ describe('popup placement', function() ]]) end) - it('works with preview-window above and inverted', function() - feed(':ped<CR><c-w>4+') + it('works with preview-window above and tall and inverted', function() + feed(':ped<CR><c-w>8+') feed('iaa<cr>bb<cr>cc<cr>dd<cr>ee<cr>') feed('ff<cr>gg<cr>hh<cr>ii<cr>jj<cr>') + feed('kk<cr>ll<cr>mm<cr>nn<cr>oo<cr>') feed('<c-x><c-n>') screen:expect([[ aa | bb | cc | dd | - ee | - ff | - gg | - hh | - {3:[No Name] [Preview][+] }| + {s:aa }{c: }{3:ew][+] }| + {n:bb }{c: } | + {n:cc }{c: } | + {n:dd }{c: } | + {n:ee }{c: } | + {n:ff }{c: } | + {n:gg }{c: } | + {n:hh }{c: } | + {n:ii }{c: } | + {n:jj }{c: } | + {n:kk }{c: } | + {n:ll }{s: } | + {n:mm }{s: } | + aa^ | + {4:[No Name] [+] }| + {2:-- }{5:match 1 of 15} | + ]]) + end) + + it('works with preview-window above and short and inverted', function() + feed(':ped<CR><c-w>4+') + feed('iaa<cr>bb<cr>cc<cr>dd<cr>ee<cr>') + feed('ff<cr>gg<cr>hh<cr>ii<cr>jj<cr>') + feed('<c-x><c-n>') + screen:expect([[ + aa | + bb | cc | dd | ee | ff | gg | - hh | - {s:aa }{c: } | - {n:bb }{s: } | + {s:aa } | + {n:bb }{3:iew][+] }| + {n:cc } | + {n:dd } | + {n:ee } | + {n:ff } | + {n:gg } | + {n:hh } | + {n:ii } | + {n:jj } | aa^ | {4:[No Name] [+] }| {2:-- }{5:match 1 of 10} | |