mirror of
https://github.com/neovim/neovim.git
synced 2025-09-06 19:38:20 +00:00
Merge pull request #33114 from zeertzjq/vim-9.1.1250
vim-patch:9.1.{1250,1255,1257}: 'pummaxwidth'
This commit is contained in:
@@ -79,6 +79,7 @@ LUA
|
|||||||
OPTIONS
|
OPTIONS
|
||||||
|
|
||||||
• 'diffopt' `inline:` configures diff highlighting for changes within a line.
|
• 'diffopt' `inline:` configures diff highlighting for changes within a line.
|
||||||
|
• 'pummaxwidth' sets maximum width for the completion popup menu.
|
||||||
|
|
||||||
PLUGINS
|
PLUGINS
|
||||||
|
|
||||||
|
@@ -4623,6 +4623,14 @@ A jump table for the options with a short description can be found at |Q_op|.
|
|||||||
Maximum number of items to show in the popup menu
|
Maximum number of items to show in the popup menu
|
||||||
(|ins-completion-menu|). Zero means "use available screen space".
|
(|ins-completion-menu|). Zero means "use available screen space".
|
||||||
|
|
||||||
|
*'pummaxwidth'* *'pmw'*
|
||||||
|
'pummaxwidth' 'pmw' number (default 0)
|
||||||
|
global
|
||||||
|
Maximum width for the popup menu (|ins-completion-menu|). When zero,
|
||||||
|
there is no maximum width limit, otherwise the popup menu will never be
|
||||||
|
wider than this value. Truncated text will be indicated by "..." at the
|
||||||
|
end. Takes precedence over 'pumwidth'.
|
||||||
|
|
||||||
*'pumwidth'* *'pw'*
|
*'pumwidth'* *'pw'*
|
||||||
'pumwidth' 'pw' number (default 15)
|
'pumwidth' 'pw' number (default 15)
|
||||||
global
|
global
|
||||||
|
11
runtime/lua/vim/_meta/options.lua
generated
11
runtime/lua/vim/_meta/options.lua
generated
@@ -4802,6 +4802,17 @@ vim.o.ph = vim.o.pumheight
|
|||||||
vim.go.pumheight = vim.o.pumheight
|
vim.go.pumheight = vim.o.pumheight
|
||||||
vim.go.ph = vim.go.pumheight
|
vim.go.ph = vim.go.pumheight
|
||||||
|
|
||||||
|
--- Maximum width for the popup menu (`ins-completion-menu`). When zero,
|
||||||
|
--- there is no maximum width limit, otherwise the popup menu will never be
|
||||||
|
--- wider than this value. Truncated text will be indicated by "..." at the
|
||||||
|
--- end. Takes precedence over 'pumwidth'.
|
||||||
|
---
|
||||||
|
--- @type integer
|
||||||
|
vim.o.pummaxwidth = 0
|
||||||
|
vim.o.pmw = vim.o.pummaxwidth
|
||||||
|
vim.go.pummaxwidth = vim.o.pummaxwidth
|
||||||
|
vim.go.pmw = vim.go.pummaxwidth
|
||||||
|
|
||||||
--- Minimum width for the popup menu (`ins-completion-menu`). If the
|
--- Minimum width for the popup menu (`ins-completion-menu`). If the
|
||||||
--- cursor column + 'pumwidth' exceeds screen width, the popup menu is
|
--- cursor column + 'pumwidth' exceeds screen width, the popup menu is
|
||||||
--- nudged to fit on the screen.
|
--- nudged to fit on the screen.
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
" These commands create the option window.
|
" These commands create the option window.
|
||||||
"
|
"
|
||||||
" Maintainer: The Vim Project <https://github.com/vim/vim>
|
" Maintainer: The Vim Project <https://github.com/vim/vim>
|
||||||
" Last Change: 2025 Mar 07
|
" Last Change: 2025 Mar 28
|
||||||
" Former Maintainer: Bram Moolenaar <Bram@vim.org>
|
" Former Maintainer: Bram Moolenaar <Bram@vim.org>
|
||||||
|
|
||||||
" If there already is an option window, jump to that one.
|
" If there already is an option window, jump to that one.
|
||||||
@@ -736,6 +736,8 @@ if has("insert_expand")
|
|||||||
call <SID>OptionG("ph", &ph)
|
call <SID>OptionG("ph", &ph)
|
||||||
call <SID>AddOption("pumwidth", gettext("minimum width of the popup menu"))
|
call <SID>AddOption("pumwidth", gettext("minimum width of the popup menu"))
|
||||||
call <SID>OptionG("pw", &pw)
|
call <SID>OptionG("pw", &pw)
|
||||||
|
call <SID>AddOption("pummaxwidth", gettext("maximum width of the popup menu"))
|
||||||
|
call <SID>OptionG("pmw", &pmw)
|
||||||
call <SID>AddOption("completefunc", gettext("user defined function for Insert mode completion"))
|
call <SID>AddOption("completefunc", gettext("user defined function for Insert mode completion"))
|
||||||
call append("$", "\t" .. s:local_to_buffer)
|
call append("$", "\t" .. s:local_to_buffer)
|
||||||
call <SID>OptionL("cfu")
|
call <SID>OptionL("cfu")
|
||||||
|
@@ -306,6 +306,7 @@ EXTERN char *p_csl; ///< 'completeslash'
|
|||||||
EXTERN OptInt p_pb; ///< 'pumblend'
|
EXTERN OptInt p_pb; ///< 'pumblend'
|
||||||
EXTERN OptInt p_ph; ///< 'pumheight'
|
EXTERN OptInt p_ph; ///< 'pumheight'
|
||||||
EXTERN OptInt p_pw; ///< 'pumwidth'
|
EXTERN OptInt p_pw; ///< 'pumwidth'
|
||||||
|
EXTERN OptInt p_pmw; ///< 'pummaxwidth'
|
||||||
EXTERN char *p_com; ///< 'comments'
|
EXTERN char *p_com; ///< 'comments'
|
||||||
EXTERN char *p_cpo; ///< 'cpoptions'
|
EXTERN char *p_cpo; ///< 'cpoptions'
|
||||||
EXTERN char *p_debug; ///< 'debug'
|
EXTERN char *p_debug; ///< 'debug'
|
||||||
|
@@ -6425,6 +6425,21 @@ local options = {
|
|||||||
type = 'number',
|
type = 'number',
|
||||||
varname = 'p_ph',
|
varname = 'p_ph',
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
abbreviation = 'pmw',
|
||||||
|
defaults = 0,
|
||||||
|
desc = [=[
|
||||||
|
Maximum width for the popup menu (|ins-completion-menu|). When zero,
|
||||||
|
there is no maximum width limit, otherwise the popup menu will never be
|
||||||
|
wider than this value. Truncated text will be indicated by "..." at the
|
||||||
|
end. Takes precedence over 'pumwidth'.
|
||||||
|
]=],
|
||||||
|
full_name = 'pummaxwidth',
|
||||||
|
scope = { 'global' },
|
||||||
|
short_desc = N_('maximum width of the popup menu'),
|
||||||
|
type = 'number',
|
||||||
|
varname = 'p_pmw',
|
||||||
|
},
|
||||||
{
|
{
|
||||||
abbreviation = 'pw',
|
abbreviation = 'pw',
|
||||||
defaults = 15,
|
defaults = 15,
|
||||||
|
@@ -199,6 +199,9 @@ void pum_display(pumitem_T *array, int size, int selected, bool array_changed, i
|
|||||||
}
|
}
|
||||||
|
|
||||||
int def_width = (int)p_pw;
|
int def_width = (int)p_pw;
|
||||||
|
if (p_pmw > 0 && def_width > p_pmw) {
|
||||||
|
def_width = (int)p_pmw;
|
||||||
|
}
|
||||||
|
|
||||||
win_T *pvwin = NULL;
|
win_T *pvwin = NULL;
|
||||||
FOR_ALL_WINDOWS_IN_TAB(wp, curtab) {
|
FOR_ALL_WINDOWS_IN_TAB(wp, curtab) {
|
||||||
@@ -307,6 +310,9 @@ void pum_display(pumitem_T *array, int size, int selected, bool array_changed, i
|
|||||||
|
|
||||||
pum_compute_size();
|
pum_compute_size();
|
||||||
int max_width = pum_base_width;
|
int max_width = pum_base_width;
|
||||||
|
if (p_pmw > 0 && max_width > p_pmw) {
|
||||||
|
max_width = (int)p_pmw;
|
||||||
|
}
|
||||||
|
|
||||||
// if there are more items than room we need a scrollbar
|
// if there are more items than room we need a scrollbar
|
||||||
if (pum_height < size) {
|
if (pum_height < size) {
|
||||||
@@ -339,6 +345,9 @@ void pum_display(pumitem_T *array, int size, int selected, bool array_changed, i
|
|||||||
if (pum_width > content_width && pum_width > p_pw) {
|
if (pum_width > content_width && pum_width > p_pw) {
|
||||||
// Reduce width to fit item
|
// Reduce width to fit item
|
||||||
pum_width = MAX(content_width, (int)p_pw);
|
pum_width = MAX(content_width, (int)p_pw);
|
||||||
|
if (p_pmw > 0 && pum_width > p_pmw) {
|
||||||
|
pum_width = (int)p_pmw;
|
||||||
|
}
|
||||||
} else if (((cursor_col - min_col > p_pw
|
} else if (((cursor_col - min_col > p_pw
|
||||||
|| cursor_col - min_col > max_width) && !pum_rl)
|
|| cursor_col - min_col > max_width) && !pum_rl)
|
||||||
|| (pum_rl && (cursor_col < max_col - p_pw
|
|| (pum_rl && (cursor_col < max_col - p_pw
|
||||||
@@ -365,6 +374,9 @@ void pum_display(pumitem_T *array, int size, int selected, bool array_changed, i
|
|||||||
|
|
||||||
if (pum_width < p_pw) {
|
if (pum_width < p_pw) {
|
||||||
pum_width = (int)p_pw;
|
pum_width = (int)p_pw;
|
||||||
|
if (p_pmw > 0 && pum_width > p_pmw) {
|
||||||
|
pum_width = (int)p_pmw;
|
||||||
|
}
|
||||||
if (pum_rl) {
|
if (pum_rl) {
|
||||||
if (pum_width > pum_col - min_col) {
|
if (pum_width > pum_col - min_col) {
|
||||||
pum_width = pum_col - min_col;
|
pum_width = pum_col - min_col;
|
||||||
@@ -376,6 +388,11 @@ void pum_display(pumitem_T *array, int size, int selected, bool array_changed, i
|
|||||||
}
|
}
|
||||||
} else if (pum_width > content_width && pum_width > p_pw) {
|
} else if (pum_width > content_width && pum_width > p_pw) {
|
||||||
pum_width = MAX(content_width, (int)p_pw);
|
pum_width = MAX(content_width, (int)p_pw);
|
||||||
|
if (p_pmw > 0 && pum_width > p_pmw) {
|
||||||
|
pum_width = (int)p_pmw;
|
||||||
|
}
|
||||||
|
} else if (p_pmw > 0 && pum_width > p_pmw) {
|
||||||
|
pum_width = (int)p_pmw;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (max_col - min_col < def_width) {
|
} else if (max_col - min_col < def_width) {
|
||||||
@@ -386,11 +403,17 @@ void pum_display(pumitem_T *array, int size, int selected, bool array_changed, i
|
|||||||
pum_col = min_col;
|
pum_col = min_col;
|
||||||
}
|
}
|
||||||
pum_width = max_col - min_col - 1;
|
pum_width = max_col - min_col - 1;
|
||||||
|
if (p_pmw > 0 && pum_width > p_pmw) {
|
||||||
|
pum_width = (int)p_pmw;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
if (max_width > p_pw) {
|
if (max_width > p_pw) {
|
||||||
// truncate
|
// truncate
|
||||||
max_width = (int)p_pw;
|
max_width = (int)p_pw;
|
||||||
}
|
}
|
||||||
|
if (p_pmw > 0 && max_width > p_pmw) {
|
||||||
|
max_width = (int)p_pmw;
|
||||||
|
}
|
||||||
if (pum_rl) {
|
if (pum_rl) {
|
||||||
pum_col = min_col + max_width - 1;
|
pum_col = min_col + max_width - 1;
|
||||||
} else {
|
} else {
|
||||||
@@ -611,6 +634,8 @@ void pum_redraw(void)
|
|||||||
thumb_pos = (pum_first * (pum_height - thumb_height) + scroll_range / 2) / scroll_range;
|
thumb_pos = (pum_first * (pum_height - thumb_height) + scroll_range / 2) / scroll_range;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const int ellipsis_width = 3;
|
||||||
|
|
||||||
for (int i = 0; i < pum_height; i++) {
|
for (int i = 0; i < pum_height; i++) {
|
||||||
int idx = i + pum_first;
|
int idx = i + pum_first;
|
||||||
const hlf_T *const hlfs = (idx == pum_selected) ? hlfsSel : hlfsNorm;
|
const hlf_T *const hlfs = (idx == pum_selected) ? hlfsSel : hlfsNorm;
|
||||||
@@ -633,6 +658,7 @@ void pum_redraw(void)
|
|||||||
// Do this 3 times and order from p_cia
|
// Do this 3 times and order from p_cia
|
||||||
int grid_col = col_off;
|
int grid_col = col_off;
|
||||||
int totwidth = 0;
|
int totwidth = 0;
|
||||||
|
bool need_ellipsis = false;
|
||||||
int order[3];
|
int order[3];
|
||||||
int items_width_array[3] = { pum_base_width, pum_kind_width, pum_extra_width };
|
int items_width_array[3] = { pum_base_width, pum_kind_width, pum_extra_width };
|
||||||
pum_align_order(order);
|
pum_align_order(order);
|
||||||
@@ -684,7 +710,11 @@ void pum_redraw(void)
|
|||||||
if (pum_rl) {
|
if (pum_rl) {
|
||||||
char *rt = reverse_text(st);
|
char *rt = reverse_text(st);
|
||||||
char *rt_start = rt;
|
char *rt_start = rt;
|
||||||
int cells = vim_strsize(rt);
|
int cells = (int)mb_string2cells(rt);
|
||||||
|
if (p_pmw > ellipsis_width && pum_width == p_pmw
|
||||||
|
&& grid_col - cells < col_off - pum_width) {
|
||||||
|
need_ellipsis = true;
|
||||||
|
}
|
||||||
|
|
||||||
if (grid_col - cells < col_off - pum_width) {
|
if (grid_col - cells < col_off - pum_width) {
|
||||||
do {
|
do {
|
||||||
@@ -710,10 +740,16 @@ void pum_redraw(void)
|
|||||||
xfree(st);
|
xfree(st);
|
||||||
grid_col -= width;
|
grid_col -= width;
|
||||||
} else {
|
} else {
|
||||||
|
int cells = (int)mb_string2cells(st);
|
||||||
|
if (p_pmw > ellipsis_width && pum_width == p_pmw
|
||||||
|
&& grid_col + cells > col_off + pum_width) {
|
||||||
|
need_ellipsis = true;
|
||||||
|
}
|
||||||
|
|
||||||
if (attrs == NULL) {
|
if (attrs == NULL) {
|
||||||
grid_line_puts(grid_col, st, -1, attr);
|
grid_line_puts(grid_col, st, -1, attr);
|
||||||
} else {
|
} else {
|
||||||
pum_grid_puts_with_attrs(grid_col, vim_strsize(st), st, -1, attrs);
|
pum_grid_puts_with_attrs(grid_col, cells, st, -1, attrs);
|
||||||
}
|
}
|
||||||
|
|
||||||
xfree(st);
|
xfree(st);
|
||||||
@@ -772,9 +808,24 @@ void pum_redraw(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (pum_rl) {
|
if (pum_rl) {
|
||||||
grid_line_fill(col_off - pum_width + 1, grid_col + 1, schar_from_ascii(' '), orig_attr);
|
const int lcol = col_off - pum_width + 1;
|
||||||
|
grid_line_fill(lcol, grid_col + 1, schar_from_ascii(' '), orig_attr);
|
||||||
|
if (need_ellipsis) {
|
||||||
|
bool over_wide = pum_width > ellipsis_width && linebuf_char[lcol + ellipsis_width] == NUL;
|
||||||
|
grid_line_fill(lcol, lcol + ellipsis_width, schar_from_ascii('.'), orig_attr);
|
||||||
|
if (over_wide) {
|
||||||
|
grid_line_put_schar(lcol + ellipsis_width, schar_from_ascii(' '), orig_attr);
|
||||||
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
grid_line_fill(grid_col, col_off + pum_width, schar_from_ascii(' '), orig_attr);
|
const int rcol = col_off + pum_width;
|
||||||
|
grid_line_fill(grid_col, rcol, schar_from_ascii(' '), orig_attr);
|
||||||
|
if (need_ellipsis) {
|
||||||
|
if (pum_width > ellipsis_width && linebuf_char[rcol - ellipsis_width] == NUL) {
|
||||||
|
grid_line_put_schar(rcol - ellipsis_width - 1, schar_from_ascii(' '), orig_attr);
|
||||||
|
}
|
||||||
|
grid_line_fill(rcol - ellipsis_width, rcol, schar_from_ascii('.'), orig_attr);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pum_scrollbar > 0) {
|
if (pum_scrollbar > 0) {
|
||||||
|
@@ -5478,7 +5478,471 @@ describe('builtin popupmenu', function()
|
|||||||
end
|
end
|
||||||
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<C-X><C-N>')
|
||||||
|
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('<Esc>3Gdd"zp')
|
||||||
|
|
||||||
|
command('set pummaxwidth=10')
|
||||||
|
feed('GA<C-X><C-N>')
|
||||||
|
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('<Esc>3Gdd"zp')
|
||||||
|
|
||||||
|
command('set pummaxwidth=20')
|
||||||
|
feed('GA<C-X><C-N>')
|
||||||
|
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('<Esc>3Gdd"zp')
|
||||||
|
|
||||||
|
command('set pumwidth=20 pummaxwidth=8')
|
||||||
|
feed('GA<C-X><C-N>')
|
||||||
|
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('<Esc>3Gdd"zp')
|
||||||
|
|
||||||
|
screen:try_resize(32, 10)
|
||||||
|
feed('GA<C-X><C-N>')
|
||||||
|
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('<Esc>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<C-X><C-O>')
|
||||||
|
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('<Esc>')
|
||||||
|
|
||||||
|
command('set pummaxwidth=10')
|
||||||
|
feed('S<C-X><C-O>')
|
||||||
|
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('<Esc>')
|
||||||
|
|
||||||
|
command('set rightleft')
|
||||||
|
feed('S<C-X><C-O>')
|
||||||
|
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('<Esc>')
|
||||||
|
command('set norightleft')
|
||||||
|
|
||||||
|
command('set pummaxwidth=2')
|
||||||
|
feed('S<C-X><C-O>')
|
||||||
|
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('<Esc>')
|
||||||
|
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<C-X><C-O>')
|
||||||
|
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('<Esc>')
|
||||||
|
|
||||||
|
command('set rightleft')
|
||||||
|
feed('S<C-X><C-O>')
|
||||||
|
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('<Esc>')
|
||||||
|
command('set norightleft')
|
||||||
|
|
||||||
|
command('set pummaxwidth=13')
|
||||||
|
feed('S<C-X><C-O>')
|
||||||
|
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('<Esc>')
|
||||||
|
|
||||||
|
command('set rightleft')
|
||||||
|
feed('S<C-X><C-O>')
|
||||||
|
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('<Esc>')
|
||||||
|
command('set norightleft')
|
||||||
|
end)
|
||||||
|
|
||||||
|
it('does not crash when displayed in last column with rightleft #12032', function()
|
||||||
local col = 30
|
local col = 30
|
||||||
local items = { 'word', 'choice', 'text', 'thing' }
|
local items = { 'word', 'choice', 'text', 'thing' }
|
||||||
local max_len = 0
|
local max_len = 0
|
||||||
|
@@ -1992,4 +1992,86 @@ func Test_pum_complete_with_special_characters()
|
|||||||
call StopVimInTerminal(buf)
|
call StopVimInTerminal(buf)
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
func Test_pum_maxwidth()
|
||||||
|
CheckScreendump
|
||||||
|
|
||||||
|
let lines =<< trim END
|
||||||
|
123456789_123456789_123456789_a
|
||||||
|
123456789_123456789_123456789_b
|
||||||
|
123
|
||||||
|
END
|
||||||
|
call writefile(lines, 'Xtest', 'D')
|
||||||
|
let buf = RunVimInTerminal('Xtest', {})
|
||||||
|
|
||||||
|
call term_sendkeys(buf, "G\"zyy")
|
||||||
|
call term_sendkeys(buf, "A\<C-N>")
|
||||||
|
call VerifyScreenDump(buf, 'Test_pum_maxwidth_01', {'rows': 8})
|
||||||
|
call term_sendkeys(buf, "\<Esc>3Gdd\"zp")
|
||||||
|
|
||||||
|
call term_sendkeys(buf, ":set pummaxwidth=10\<CR>")
|
||||||
|
call term_sendkeys(buf, "GA\<C-N>")
|
||||||
|
call VerifyScreenDump(buf, 'Test_pum_maxwidth_02', {'rows': 8})
|
||||||
|
call term_sendkeys(buf, "\<Esc>3Gdd\"zp")
|
||||||
|
|
||||||
|
call term_sendkeys(buf, ":set pummaxwidth=20\<CR>")
|
||||||
|
call term_sendkeys(buf, "GA\<C-N>")
|
||||||
|
call VerifyScreenDump(buf, 'Test_pum_maxwidth_03', {'rows': 8})
|
||||||
|
call term_sendkeys(buf, "\<Esc>3Gdd\"zp")
|
||||||
|
|
||||||
|
call term_sendkeys(buf, ":set pumwidth=20 pummaxwidth=8\<CR>")
|
||||||
|
call term_sendkeys(buf, "GA\<C-N>")
|
||||||
|
call VerifyScreenDump(buf, 'Test_pum_maxwidth_04', {'rows': 8})
|
||||||
|
call term_sendkeys(buf, "\<Esc>3Gdd\"zp")
|
||||||
|
|
||||||
|
call term_sendkeys(buf, ":set lines=10 columns=32\<CR>")
|
||||||
|
call term_sendkeys(buf, "GA\<C-N>")
|
||||||
|
call VerifyScreenDump(buf, 'Test_pum_maxwidth_09', {'rows': 10, 'cols': 32})
|
||||||
|
call term_sendkeys(buf, "\<Esc>3Gdd\"zp")
|
||||||
|
|
||||||
|
call StopVimInTerminal(buf)
|
||||||
|
endfunc
|
||||||
|
|
||||||
|
func Test_pum_maxwidth_multibyte()
|
||||||
|
CheckScreendump
|
||||||
|
|
||||||
|
let lines =<< trim END
|
||||||
|
func Omni_test(findstart, base)
|
||||||
|
if a:findstart
|
||||||
|
return col(".")
|
||||||
|
endif
|
||||||
|
return [
|
||||||
|
\ #{word: "123456789_123456789_123456789_"},
|
||||||
|
\ #{word: "一二三四五六七八九十"},
|
||||||
|
\ ]
|
||||||
|
endfunc
|
||||||
|
set omnifunc=Omni_test
|
||||||
|
END
|
||||||
|
call writefile(lines, 'Xtest', 'D')
|
||||||
|
let buf = RunVimInTerminal('-S Xtest', {})
|
||||||
|
call TermWait(buf)
|
||||||
|
|
||||||
|
call term_sendkeys(buf, "S\<C-X>\<C-O>")
|
||||||
|
call VerifyScreenDump(buf, 'Test_pum_maxwidth_05', {'rows': 8})
|
||||||
|
call term_sendkeys(buf, "\<ESC>")
|
||||||
|
|
||||||
|
call term_sendkeys(buf, ":set pummaxwidth=10\<CR>")
|
||||||
|
call term_sendkeys(buf, "S\<C-X>\<C-O>")
|
||||||
|
call VerifyScreenDump(buf, 'Test_pum_maxwidth_06', {'rows': 8})
|
||||||
|
call term_sendkeys(buf, "\<ESC>")
|
||||||
|
|
||||||
|
if has('rightleft')
|
||||||
|
call term_sendkeys(buf, ":set rightleft\<CR>")
|
||||||
|
call term_sendkeys(buf, "S\<C-X>\<C-O>")
|
||||||
|
call VerifyScreenDump(buf, 'Test_pum_maxwidth_07', {'rows': 8})
|
||||||
|
call term_sendkeys(buf, "\<Esc>:set norightleft\<CR>")
|
||||||
|
endif
|
||||||
|
|
||||||
|
call term_sendkeys(buf, ":set pummaxwidth=2\<CR>")
|
||||||
|
call term_sendkeys(buf, "S\<C-X>\<C-O>")
|
||||||
|
call VerifyScreenDump(buf, 'Test_pum_maxwidth_08', {'rows': 8})
|
||||||
|
call term_sendkeys(buf, "\<ESC>")
|
||||||
|
|
||||||
|
call StopVimInTerminal(buf)
|
||||||
|
endfunc
|
||||||
|
|
||||||
" vim: shiftwidth=2 sts=2 expandtab
|
" vim: shiftwidth=2 sts=2 expandtab
|
||||||
|
Reference in New Issue
Block a user