From 62da4e2949cc906102bd768cdd40b274623822b6 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Fri, 28 Mar 2025 15:37:49 +0800 Subject: vim-patch:9.1.1250: cannot set the maximum popup menu width Problem: cannot set the maximum popup menu width (Lucas Mior) Solution: add the new global option value 'pummaxwidth' (glepnir) fixes: vim/vim#10901 closes: vim/vim#16943 https://github.com/vim/vim/commit/88d75934c3d5bc4c406343f106e1a61638abd3a7 Co-authored-by: glepnir --- test/functional/ui/popupmenu_spec.lua | 284 +++++++++++++++++++++++++++++++++- 1 file changed, 283 insertions(+), 1 deletion(-) (limited to 'test/functional') diff --git a/test/functional/ui/popupmenu_spec.lua b/test/functional/ui/popupmenu_spec.lua index 0b7cff168b..7469269a1b 100644 --- a/test/functional/ui/popupmenu_spec.lua +++ b/test/functional/ui/popupmenu_spec.lua @@ -5478,7 +5478,289 @@ describe('builtin popupmenu', function() end end) - it('does not crash when displayed in the last column with rightleft #12032', function() + -- oldtest: Test_pum_maxwidth() + it('"pummaxwidth"', function() + screen:try_resize(60, 8) + api.nvim_buf_set_lines(0, 0, -1, true, { + '123456789_123456789_123456789_a', + '123456789_123456789_123456789_b', + ' 123', + }) + feed('G"zyy') + feed('A') + if multigrid then + screen:expect({ + grid = [[ + ## grid 1 + [2:------------------------------------------------------------]|*7 + [3:------------------------------------------------------------]| + ## grid 2 + 123456789_123456789_123456789_a | + 123456789_123456789_123456789_b | + 123456789_123456789_123456789_a^ | + {1:~ }|*4 + ## grid 3 + {2:-- Keyword Local completion (^N^P) }{5:match 1 of 2} | + ## grid 4 + {s: 123456789_123456789_123456789_a }| + {n: 123456789_123456789_123456789_b }| + ]], + float_pos = { [4] = { -1, 'NW', 2, 3, 11, false, 100 } }, + }) + else + screen:expect([[ + 123456789_123456789_123456789_a | + 123456789_123456789_123456789_b | + 123456789_123456789_123456789_a^ | + {1:~ }{s: 123456789_123456789_123456789_a }{1: }| + {1:~ }{n: 123456789_123456789_123456789_b }{1: }| + {1:~ }|*2 + {2:-- Keyword Local completion (^N^P) }{5:match 1 of 2} | + ]]) + end + feed('3Gdd"zp') + + command('set pummaxwidth=10') + feed('GA') + if multigrid then + screen:expect({ + grid = [[ + ## grid 1 + [2:------------------------------------------------------------]|*7 + [3:------------------------------------------------------------]| + ## grid 2 + 123456789_123456789_123456789_a | + 123456789_123456789_123456789_b | + 123456789_123456789_123456789_a^ | + {1:~ }|*4 + ## grid 3 + {2:-- Keyword Local completion (^N^P) }{5:match 1 of 2} | + ## grid 4 + {s: 1234567...}| + {n: 1234567...}| + ]], + float_pos = { [4] = { -1, 'NW', 2, 3, 11, false, 100 } }, + }) + else + screen:expect([[ + 123456789_123456789_123456789_a | + 123456789_123456789_123456789_b | + 123456789_123456789_123456789_a^ | + {1:~ }{s: 1234567...}{1: }| + {1:~ }{n: 1234567...}{1: }| + {1:~ }|*2 + {2:-- Keyword Local completion (^N^P) }{5:match 1 of 2} | + ]]) + end + feed('3Gdd"zp') + + command('set pummaxwidth=20') + feed('GA') + if multigrid then + screen:expect({ + grid = [[ + ## grid 1 + [2:------------------------------------------------------------]|*7 + [3:------------------------------------------------------------]| + ## grid 2 + 123456789_123456789_123456789_a | + 123456789_123456789_123456789_b | + 123456789_123456789_123456789_a^ | + {1:~ }|*4 + ## grid 3 + {2:-- Keyword Local completion (^N^P) }{5:match 1 of 2} | + ## grid 4 + {s: 123456789_1234567...}| + {n: 123456789_1234567...}| + ]], + float_pos = { [4] = { -1, 'NW', 2, 3, 11, false, 100 } }, + }) + else + screen:expect([[ + 123456789_123456789_123456789_a | + 123456789_123456789_123456789_b | + 123456789_123456789_123456789_a^ | + {1:~ }{s: 123456789_1234567...}{1: }| + {1:~ }{n: 123456789_1234567...}{1: }| + {1:~ }|*2 + {2:-- Keyword Local completion (^N^P) }{5:match 1 of 2} | + ]]) + end + feed('3Gdd"zp') + + command('set pumwidth=20 pummaxwidth=8') + feed('GA') + if multigrid then + screen:expect({ + grid = [[ + ## grid 1 + [2:------------------------------------------------------------]|*7 + [3:------------------------------------------------------------]| + ## grid 2 + 123456789_123456789_123456789_a | + 123456789_123456789_123456789_b | + 123456789_123456789_123456789_a^ | + {1:~ }|*4 + ## grid 3 + {2:-- Keyword Local completion (^N^P) }{5:match 1 of 2} | + ## grid 4 + {s: 12345...}| + {n: 12345...}| + ]], + float_pos = { [4] = { -1, 'NW', 2, 3, 11, false, 100 } }, + }) + else + screen:expect([[ + 123456789_123456789_123456789_a | + 123456789_123456789_123456789_b | + 123456789_123456789_123456789_a^ | + {1:~ }{s: 12345...}{1: }| + {1:~ }{n: 12345...}{1: }| + {1:~ }|*2 + {2:-- Keyword Local completion (^N^P) }{5:match 1 of 2} | + ]]) + end + feed('3Gdd"zp') + end) + + -- oldtest: Test_pum_maxwidth_multibyte() + it("'pummaxwidth' with multibyte", function() + screen:try_resize(60, 8) + exec([[ + func Omni_test(findstart, base) + if a:findstart + return col(".") + endif + return [ + \ #{word: "123456789_123456789_123456789_"}, + \ #{word: "一二三四五六七八九十"}, + \ ] + endfunc + set omnifunc=Omni_test + ]]) + + feed('S') + if multigrid then + screen:expect({ + grid = [[ + ## grid 1 + [2:------------------------------------------------------------]|*7 + [3:------------------------------------------------------------]| + ## grid 2 + 123456789_123456789_123456789_^ | + {1:~ }|*6 + ## grid 3 + {2:-- Omni completion (^O^N^P) }{5:match 1 of 2} | + ## grid 4 + {s:123456789_123456789_123456789_ }| + {n:一二三四五六七八九十 }| + ]], + float_pos = { [4] = { -1, 'NW', 2, 1, 0, false, 100 } }, + }) + else + screen:expect([[ + 123456789_123456789_123456789_^ | + {s:123456789_123456789_123456789_ }{1: }| + {n:一二三四五六七八九十 }{1: }| + {1:~ }|*4 + {2:-- Omni completion (^O^N^P) }{5:match 1 of 2} | + ]]) + end + feed('') + + command('set pummaxwidth=10') + feed('S') + if multigrid then + screen:expect({ + grid = [[ + ## grid 1 + [2:------------------------------------------------------------]|*7 + [3:------------------------------------------------------------]| + ## grid 2 + 123456789_123456789_123456789_^ | + {1:~ }|*6 + ## grid 3 + {2:-- Omni completion (^O^N^P) }{5:match 1 of 2} | + ## grid 4 + {s:1234567...}| + {n:一二三 ...}| + ]], + float_pos = { [4] = { -1, 'NW', 2, 1, 0, false, 100 } }, + }) + else + screen:expect([[ + 123456789_123456789_123456789_^ | + {s:1234567...}{1: }| + {n:一二三 ...}{1: }| + {1:~ }|*4 + {2:-- Omni completion (^O^N^P) }{5:match 1 of 2} | + ]]) + end + feed('') + + command('set rightleft') + feed('S') + if multigrid then + screen:expect({ + grid = [[ + ## grid 1 + [2:------------------------------------------------------------]|*7 + [3:------------------------------------------------------------]| + ## grid 2 + ^ _987654321_987654321_987654321| + {1: ~}|*6 + ## grid 3 + {2:-- Omni completion (^O^N^P) }{5:match 1 of 2} | + ## grid 4 + {s:...7654321}| + {n:... 三二一}| + ]], + float_pos = { [4] = { -1, 'NW', 2, 1, 50, false, 100 } }, + }) + else + screen:expect([[ + ^ _987654321_987654321_987654321| + {1: }{s:...7654321}| + {1: }{n:... 三二一}| + {1: ~}|*4 + {2:-- Omni completion (^O^N^P) }{5:match 1 of 2} | + ]]) + end + feed('') + command('set norightleft') + + command('set pummaxwidth=2') + feed('S') + if multigrid then + screen:expect({ + grid = [[ + ## grid 1 + [2:------------------------------------------------------------]|*7 + [3:------------------------------------------------------------]| + ## grid 2 + 123456789_123456789_123456789_^ | + {1:~ }|*6 + ## grid 3 + {2:-- Omni completion (^O^N^P) }{5:match 1 of 2} | + ## grid 4 + {s:12}| + {n:一}| + ]], + float_pos = { [4] = { -1, 'NW', 2, 1, 0, false, 100 } }, + }) + else + screen:expect([[ + 123456789_123456789_123456789_^ | + {s:12}{1: }| + {n:一}{1: }| + {1:~ }|*4 + {2:-- Omni completion (^O^N^P) }{5:match 1 of 2} | + ]]) + end + feed('') + end) + + it('does not crash when displayed in last column with rightleft #12032', function() local col = 30 local items = { 'word', 'choice', 'text', 'thing' } local max_len = 0 -- cgit From 675ee057e06578e8d87ed2ea54ab8915caecdb0f Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sat, 29 Mar 2025 06:35:11 +0800 Subject: vim-patch:9.1.1255: missing test condition for 'pummaxwidth' setting Problem: missing test condition for 'pummaxwidth' setting, pummaxwidth not effective when width is 32 and height is 10 (after v9.1.1250) Solution: add missing comparison condition in pum_width() (glepnir) closes: vim/vim#16999 https://github.com/vim/vim/commit/532c5aec6fa8f0a3d743c7d1573d25d75dd36d5f Co-authored-by: glepnir --- test/functional/ui/popupmenu_spec.lua | 36 +++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) (limited to 'test/functional') diff --git a/test/functional/ui/popupmenu_spec.lua b/test/functional/ui/popupmenu_spec.lua index 7469269a1b..d82c24bb83 100644 --- a/test/functional/ui/popupmenu_spec.lua +++ b/test/functional/ui/popupmenu_spec.lua @@ -5621,6 +5621,42 @@ describe('builtin popupmenu', function() ]]) end feed('3Gdd"zp') + + screen:try_resize(32, 10) + feed('GA') + if multigrid then + screen:expect({ + grid = [[ + ## grid 1 + [2:--------------------------------]|*9 + [3:--------------------------------]| + ## grid 2 + 123456789_123456789_123456789_a | + 123456789_123456789_123456789_b | + 123456789_123456789_| + 123456789_a^ | + {1:~ }|*5 + ## grid 3 + {2:-- }{5:match 1 of 2} | + ## grid 4 + {s: 12345...}| + {n: 12345...}| + ]], + float_pos = { [4] = { -1, 'NW', 2, 4, 11, false, 100 } }, + }) + else + screen:expect([[ + 123456789_123456789_123456789_a | + 123456789_123456789_123456789_b | + 123456789_123456789_| + 123456789_a^ | + {1:~ }{s: 12345...}{1: }| + {1:~ }{n: 12345...}{1: }| + {1:~ }|*3 + {2:-- }{5:match 1 of 2} | + ]]) + end + feed('3Gdd"zp') end) -- oldtest: Test_pum_maxwidth_multibyte() -- cgit From 686e7aca40b850789af45ec9a97905518654b49e Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Fri, 28 Mar 2025 21:18:30 +0800 Subject: fix(pum): simplify 'pummaxwidth' truncation and avoid crash --- test/functional/ui/popupmenu_spec.lua | 146 ++++++++++++++++++++++++++++++++++ 1 file changed, 146 insertions(+) (limited to 'test/functional') diff --git a/test/functional/ui/popupmenu_spec.lua b/test/functional/ui/popupmenu_spec.lua index d82c24bb83..6404feb9cd 100644 --- a/test/functional/ui/popupmenu_spec.lua +++ b/test/functional/ui/popupmenu_spec.lua @@ -5796,6 +5796,152 @@ describe('builtin popupmenu', function() feed('') end) + it([['pummaxwidth' works with "kind" and "menu"]], function() + exec([[ + func Omni_test(findstart, base) + if a:findstart + return col(".") + endif + return [ + \ #{word: "foo", menu: "fooMenu", kind: "fooKind"}, + \ #{word: "bar", menu: "barMenu", kind: "barKind"}, + \ #{word: "baz", menu: "bazMenu", kind: "bazKind"}, + \ ] + endfunc + set omnifunc=Omni_test + ]]) + + command('set pummaxwidth=14') + feed('S') + if multigrid then + screen:expect({ + grid = [[ + ## grid 1 + [2:--------------------------------]|*19 + [3:--------------------------------]| + ## grid 2 + foo^ | + {1:~ }|*18 + ## grid 3 + {2:-- }{5:match 1 of 3} | + ## grid 4 + {s:foo fooKind...}| + {n:bar barKind...}| + {n:baz bazKind...}| + ]], + float_pos = { [4] = { -1, 'NW', 2, 1, 0, false, 100 } }, + }) + else + screen:expect([[ + foo^ | + {s:foo fooKind...}{1: }| + {n:bar barKind...}{1: }| + {n:baz bazKind...}{1: }| + {1:~ }|*15 + {2:-- }{5:match 1 of 3} | + ]]) + end + feed('') + + command('set rightleft') + feed('S') + if multigrid then + screen:expect({ + grid = [[ + ## grid 1 + [2:--------------------------------]|*19 + [3:--------------------------------]| + ## grid 2 + ^ oof| + {1: ~}|*18 + ## grid 3 + {2:-- }{5:match 1 of 3} | + ## grid 4 + {s:...dniKoof oof}| + {n:...dniKrab rab}| + {n:...dniKzab zab}| + ]], + float_pos = { [4] = { -1, 'NW', 2, 1, 18, false, 100 } }, + }) + else + screen:expect([[ + ^ oof| + {1: }{s:...dniKoof oof}| + {1: }{n:...dniKrab rab}| + {1: }{n:...dniKzab zab}| + {1: ~}|*15 + {2:-- }{5:match 1 of 3} | + ]]) + end + feed('') + command('set norightleft') + + command('set pummaxwidth=13') + feed('S') + if multigrid then + screen:expect({ + grid = [[ + ## grid 1 + [2:--------------------------------]|*19 + [3:--------------------------------]| + ## grid 2 + foo^ | + {1:~ }|*18 + ## grid 3 + {2:-- }{5:match 1 of 3} | + ## grid 4 + {s:foo fooKin...}| + {n:bar barKin...}| + {n:baz bazKin...}| + ]], + float_pos = { [4] = { -1, 'NW', 2, 1, 0, false, 100 } }, + }) + else + screen:expect([[ + foo^ | + {s:foo fooKin...}{1: }| + {n:bar barKin...}{1: }| + {n:baz bazKin...}{1: }| + {1:~ }|*15 + {2:-- }{5:match 1 of 3} | + ]]) + end + feed('') + + command('set rightleft') + feed('S') + if multigrid then + screen:expect({ + grid = [[ + ## grid 1 + [2:--------------------------------]|*19 + [3:--------------------------------]| + ## grid 2 + ^ oof| + {1: ~}|*18 + ## grid 3 + {2:-- }{5:match 1 of 3} | + ## grid 4 + {s:...niKoof oof}| + {n:...niKrab rab}| + {n:...niKzab zab}| + ]], + float_pos = { [4] = { -1, 'NW', 2, 1, 19, false, 100 } }, + }) + else + screen:expect([[ + ^ oof| + {1: }{s:...niKoof oof}| + {1: }{n:...niKrab rab}| + {1: }{n:...niKzab zab}| + {1: ~}|*15 + {2:-- }{5:match 1 of 3} | + ]]) + end + feed('') + command('set norightleft') + end) + it('does not crash when displayed in last column with rightleft #12032', function() local col = 30 local items = { 'word', 'choice', 'text', 'thing' } -- cgit