mirror of
https://github.com/neovim/neovim.git
synced 2025-09-06 11:28:22 +00:00
fix(pum): check for cmdline mode properly
Backport of #35198 and #35210
This commit is contained in:
@@ -139,10 +139,10 @@ void pum_display(pumitem_T *array, int size, int selected, bool array_changed, i
|
||||
// To keep the code simple, we only allow changing the
|
||||
// draw mode when the popup menu is not being displayed
|
||||
pum_external = ui_has(kUIPopupmenu)
|
||||
|| (State == MODE_CMDLINE && ui_has(kUIWildmenu));
|
||||
|| ((State & MODE_CMDLINE) && ui_has(kUIWildmenu));
|
||||
}
|
||||
|
||||
pum_rl = State != MODE_CMDLINE && curwin->w_p_rl;
|
||||
pum_rl = (State & MODE_CMDLINE) == 0 && curwin->w_p_rl;
|
||||
|
||||
do {
|
||||
// Mark the pum as visible already here,
|
||||
@@ -154,7 +154,7 @@ void pum_display(pumitem_T *array, int size, int selected, bool array_changed, i
|
||||
int below_row = cmdline_row;
|
||||
|
||||
// wildoptions=pum
|
||||
if (State == MODE_CMDLINE) {
|
||||
if (State & MODE_CMDLINE) {
|
||||
pum_win_row = ui_has(kUICmdline) ? 0 : cmdline_row;
|
||||
cursor_col = cmd_startcol;
|
||||
pum_anchor_grid = ui_has(kUICmdline) ? -1 : DEFAULT_GRID_HANDLE;
|
||||
@@ -244,7 +244,7 @@ void pum_display(pumitem_T *array, int size, int selected, bool array_changed, i
|
||||
// pum above "pum_win_row"
|
||||
pum_above = true;
|
||||
|
||||
if (State == MODE_CMDLINE) {
|
||||
if (State & MODE_CMDLINE) {
|
||||
// for cmdline pum, no need for context lines
|
||||
context_lines = 0;
|
||||
} else {
|
||||
@@ -268,7 +268,7 @@ void pum_display(pumitem_T *array, int size, int selected, bool array_changed, i
|
||||
// pum below "pum_win_row"
|
||||
pum_above = false;
|
||||
|
||||
if (State == MODE_CMDLINE) {
|
||||
if (State & MODE_CMDLINE) {
|
||||
// for cmdline pum, no need for context lines
|
||||
context_lines = 0;
|
||||
} else {
|
||||
@@ -404,7 +404,7 @@ void pum_display(pumitem_T *array, int size, int selected, bool array_changed, i
|
||||
// room the window size will keep changing.
|
||||
} while (pum_set_selected(selected, redo_count) && ++redo_count <= 2);
|
||||
|
||||
pum_grid.zindex = (State == MODE_CMDLINE) ? kZIndexCmdlinePopupMenu : kZIndexPopupMenu;
|
||||
pum_grid.zindex = (State & MODE_CMDLINE) ? kZIndexCmdlinePopupMenu : kZIndexPopupMenu;
|
||||
pum_redraw();
|
||||
}
|
||||
|
||||
@@ -418,15 +418,15 @@ static int *pum_compute_text_attrs(char *text, hlf_T hlf, int user_hlattr)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
char *leader = State == MODE_CMDLINE ? cmdline_compl_pattern()
|
||||
: ins_compl_leader();
|
||||
char *leader = (State & MODE_CMDLINE) ? cmdline_compl_pattern()
|
||||
: ins_compl_leader();
|
||||
if (leader == NULL || *leader == NUL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int *attrs = xmalloc(sizeof(int) * (size_t)vim_strsize(text));
|
||||
bool in_fuzzy = State == MODE_CMDLINE ? cmdline_compl_is_fuzzy()
|
||||
: (get_cot_flags() & kOptCotFlagFuzzy) != 0;
|
||||
bool in_fuzzy = (State & MODE_CMDLINE) ? cmdline_compl_is_fuzzy()
|
||||
: (get_cot_flags() & kOptCotFlagFuzzy) != 0;
|
||||
size_t leader_len = strlen(leader);
|
||||
|
||||
garray_T *ga = NULL;
|
||||
|
@@ -4130,7 +4130,7 @@ describe('builtin popupmenu', function()
|
||||
]])
|
||||
end
|
||||
|
||||
-- not rightleft on the cmdline
|
||||
-- oldtest: Test_wildmenu_pum_rightleft()
|
||||
feed('<esc>:sign ')
|
||||
if multigrid then
|
||||
screen:expect({
|
||||
@@ -4154,9 +4154,8 @@ describe('builtin popupmenu', function()
|
||||
]],
|
||||
}
|
||||
end
|
||||
|
||||
-- oldtest: Test_wildmenu_pum_rightleft()
|
||||
feed('<tab>')
|
||||
-- Not rightleft on the cmdline.
|
||||
feed('<Tab>')
|
||||
if multigrid then
|
||||
screen:expect({
|
||||
grid = [[
|
||||
@@ -4195,6 +4194,15 @@ describe('builtin popupmenu', function()
|
||||
]],
|
||||
}
|
||||
end
|
||||
|
||||
-- Behavior is the same when using 'keymap'.
|
||||
feed('<Esc>')
|
||||
command('set keymap=dvorak')
|
||||
-- ";gul" -> "sign" when using Dvorak keymap.
|
||||
feed(':<C-^>;gul <Tab>')
|
||||
screen:expect_unchanged(true)
|
||||
feed('<Esc>')
|
||||
command('set keymap&')
|
||||
end)
|
||||
|
||||
it('with rightleft vsplits', function()
|
||||
|
Reference in New Issue
Block a user