diff options
author | Raphael <glephunter@gmail.com> | 2024-04-25 21:36:18 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-04-25 21:36:18 +0800 |
commit | af8500af64571f787579b60bf0064cd05655fd51 (patch) | |
tree | f791db9d43adec625a4a8d695900c09914c74fe1 /test/functional/ui/popupmenu_spec.lua | |
parent | b13e63db1dbc1dbc7e23690653df1b7317660a2b (diff) | |
download | rneovim-af8500af64571f787579b60bf0064cd05655fd51.tar.gz rneovim-af8500af64571f787579b60bf0064cd05655fd51.tar.bz2 rneovim-af8500af64571f787579b60bf0064cd05655fd51.zip |
fix(completion): improve popup window position (#26739)
Diffstat (limited to 'test/functional/ui/popupmenu_spec.lua')
-rw-r--r-- | test/functional/ui/popupmenu_spec.lua | 207 |
1 files changed, 149 insertions, 58 deletions
diff --git a/test/functional/ui/popupmenu_spec.lua b/test/functional/ui/popupmenu_spec.lua index c3abc10424..5327de7825 100644 --- a/test/functional/ui/popupmenu_spec.lua +++ b/test/functional/ui/popupmenu_spec.lua @@ -1594,13 +1594,13 @@ describe('builtin popupmenu', function() describe('floating window preview #popup', function() it('pum popup preview', function() --row must > 10 - screen:try_resize(30, 11) + screen:try_resize(40, 11) exec([[ funct Omni_test(findstart, base) if a:findstart return col(".") - 1 endif - return [#{word: "one", info: "1info"}, #{word: "two", info: "2info"}, #{word: "three"}] + return [#{word: "one", info: "1info"}, #{word: "two", info: "2info"}, #{word: "looooooooooooooong"}] endfunc set omnifunc=Omni_test set completeopt=menu,popup @@ -1614,88 +1614,179 @@ describe('builtin popupmenu', function() autocmd CompleteChanged * call Set_info() ]]) feed('Gi<C-x><C-o>') - --floating preview in right if multigrid then screen:expect { grid = [[ ## grid 1 - [2:------------------------------]|*10 - [3:------------------------------]| + [2:----------------------------------------]|*10 + [3:----------------------------------------]| ## grid 2 - one^ | - {1:~ }|*9 + one^ | + {1:~ }|*9 ## grid 3 - {2:-- }{5:match 1 of 3} | + {2:-- }{5:match 1 of 3} | ## grid 4 {n:1info}| {n: }| ## grid 5 - {s:one }| - {n:two }| - {n:three }| + {s:one }| + {n:two }| + {n:looooooooooooooong }| ]], float_pos = { [5] = { -1, 'NW', 2, 1, 0, false, 100 }, - [4] = { 1001, 'NW', 1, 1, 15, true, 50 }, + [4] = { 1001, 'NW', 1, 1, 19, false, 50 }, + }, + win_viewport = { + [2] = { + win = 1000, + topline = 0, + botline = 2, + curline = 0, + curcol = 3, + linecount = 1, + sum_scroll_delta = 0, + }, + [4] = { + win = 1001, + topline = 0, + botline = 2, + curline = 0, + curcol = 0, + linecount = 1, + sum_scroll_delta = 0, + }, }, } else screen:expect { grid = [[ - one^ | - {s:one }{n:1info}{1: }| - {n:two }{1: }| - {n:three }{1: }| - {1:~ }|*6 - {2:-- }{5:match 1 of 3} | + one^ | + {s:one }{n:1info}{1: }| + {n:two }{1: }| + {n:looooooooooooooong }{1: }| + {1:~ }|*6 + {2:-- }{5:match 1 of 3} | ]], - unchanged = true, } end - -- test nvim_complete_set_info - feed('<C-N><C-N>') - vim.uv.sleep(10) + -- info window position should be adjusted when new leader add + feed('<C-P>o') if multigrid then screen:expect { grid = [[ ## grid 1 - [2:------------------------------]|*10 - [3:------------------------------]| + [2:----------------------------------------]|*10 + [3:----------------------------------------]| ## grid 2 - three^ | - {1:~ }|*9 + o^ | + {1:~ }|*9 ## grid 3 - {2:-- }{5:match 3 of 3} | + {2:-- }{8:Back at original} | ## grid 4 - {n:3info}| + {n:1info}| {n: }| ## grid 5 {n:one }| - {n:two }| - {s:three }| ]], float_pos = { [5] = { -1, 'NW', 2, 1, 0, false, 100 }, - [4] = { 1001, 'NW', 1, 1, 15, true, 50 }, + [4] = { 1001, 'NW', 1, 1, 15, false, 50 }, + }, + win_viewport = { + [2] = { + win = 1000, + topline = 0, + botline = 2, + curline = 0, + curcol = 1, + linecount = 1, + sum_scroll_delta = 0, + }, + [4] = { + win = 1001, + topline = 0, + botline = 2, + curline = 0, + curcol = 0, + linecount = 1, + sum_scroll_delta = 0, + }, }, } else screen:expect { grid = [[ - three^ | - {n:one 3info}{1: }| - {n:two }{1: }| - {s:three }{1: }| - {1:~ }|*6 - {2:-- }{5:match 3 of 3} | + o^ | + {n:one 1info}{1: }| + {1:~ }{n: }{1: }| + {1:~ }|*7 + {2:-- }{8:Back at original} | + ]], + } + end + + -- test nvim_complete_set_info + feed('<ESC>cc<C-X><C-O><C-N><C-N>') + vim.uv.sleep(10) + if multigrid then + screen:expect { + grid = [[ + ## grid 1 + [2:----------------------------------------]|*10 + [3:----------------------------------------]| + ## grid 2 + looooooooooooooong^ | + {1:~ }|*9 + ## grid 3 + {2:-- }{5:match 3 of 3} | + ## grid 5 + {n:one }| + {n:two }| + {s:looooooooooooooong }| + ## grid 6 + {n:3info}| + {n: }| + ]], + float_pos = { + [5] = { -1, 'NW', 2, 1, 0, false, 100 }, + [6] = { 1002, 'NW', 1, 1, 19, false, 50 }, + }, + win_viewport = { + [2] = { + win = 1000, + topline = 0, + botline = 2, + curline = 0, + curcol = 18, + linecount = 1, + sum_scroll_delta = 0, + }, + [6] = { + win = 1002, + topline = 0, + botline = 2, + curline = 0, + curcol = 0, + linecount = 1, + sum_scroll_delta = 0, + }, + }, + } + else + screen:expect { + grid = [[ + looooooooooooooong^ | + {n:one 3info}{1: }| + {n:two }{1: }| + {s:looooooooooooooong }{1: }| + {1:~ }|*6 + {2:-- }{5:match 3 of 3} | ]], } end - -- make sure info has set - feed('<C-y>') - eq('3info', exec_lua('return vim.v.completed_item.info')) -- preview in left feed('<ESC>cc') @@ -1705,24 +1796,24 @@ describe('builtin popupmenu', function() screen:expect { grid = [[ ## grid 1 - [2:------------------------------]|*10 - [3:------------------------------]| + [2:----------------------------------------]|*10 + [3:----------------------------------------]| ## grid 2 - itesttesttesttesttesone^t | - {1:~ }|*9 + itesttesttesttesttesone^t | + {1:~ }|*9 ## grid 3 - {2:-- }{5:match 1 of 3} | + {2:-- }{5:match 1 of 3} | ## grid 5 - {s: one }| - {n: two }| - {n: three }| - ## grid 6 + {s: one }| + {n: two }| + {n: looooooooooooooong }| + ## grid 7 {n:1info}| {n: }| ]], float_pos = { + [7] = { 1003, 'NW', 1, 1, 14, false, 50 }, [5] = { -1, 'NW', 2, 1, 19, false, 100 }, - [6] = { 1002, 'NW', 1, 1, 1, true, 50 }, }, win_viewport = { [2] = { @@ -1734,8 +1825,8 @@ describe('builtin popupmenu', function() linecount = 1, sum_scroll_delta = 0, }, - [6] = { - win = 1002, + [7] = { + win = 1003, topline = 0, botline = 2, curline = 0, @@ -1748,12 +1839,12 @@ describe('builtin popupmenu', function() else screen:expect { grid = [[ - itesttesttesttesttesone^t | - {1:~}{n:1info}{1: }{s: one }{1: }| - {1:~}{n: }{1: }{n: two }{1: }| - {1:~ }{n: three }{1: }| - {1:~ }|*6 - {2:-- }{5:match 1 of 3} | + itesttesttesttesttesone^t | + {1:~ }{n:1info}{s: one }{1: }| + {1:~ }{n: two }{1: }| + {1:~ }{n: looooooooooooooong }{1: }| + {1:~ }|*6 + {2:-- }{5:match 1 of 3} | ]], } end |