Merge pull request #35224 from zeertzjq/backport

Backport #35198 #35202 #35210
This commit is contained in:
zeertzjq
2025-08-08 06:31:10 +08:00
committed by GitHub
9 changed files with 50 additions and 23 deletions

View File

@@ -272,7 +272,7 @@ void screenclear(void)
/// to be re-emitted: avoid clearing the prompt from the message grid. /// to be re-emitted: avoid clearing the prompt from the message grid.
static bool cmdline_number_prompt(void) static bool cmdline_number_prompt(void)
{ {
return !ui_has(kUIMessages) && State == MODE_CMDLINE && get_cmdline_info()->mouse_used != NULL; return !ui_has(kUIMessages) && (State & MODE_CMDLINE) && get_cmdline_info()->mouse_used != NULL;
} }
/// Set dimensions of the Nvim application "screen". /// Set dimensions of the Nvim application "screen".
@@ -374,8 +374,8 @@ void screen_resize(int width, int height)
// - in Ex mode, don't redraw anything. // - in Ex mode, don't redraw anything.
// - Otherwise, redraw right now, and position the cursor. // - Otherwise, redraw right now, and position the cursor.
if (State == MODE_ASKMORE || State == MODE_EXTERNCMD || exmode_active if (State == MODE_ASKMORE || State == MODE_EXTERNCMD || exmode_active
|| (State == MODE_CMDLINE && get_cmdline_info()->one_key)) { || ((State & MODE_CMDLINE) && get_cmdline_info()->one_key)) {
if (State == MODE_CMDLINE) { if (State & MODE_CMDLINE) {
update_screen(); update_screen();
} }
if (msg_grid.chars) { if (msg_grid.chars) {

View File

@@ -3062,7 +3062,7 @@ void repeat_message(void)
if (State == MODE_ASKMORE) { if (State == MODE_ASKMORE) {
msg_moremsg(true); // display --more-- message again msg_moremsg(true); // display --more-- message again
msg_row = Rows - 1; msg_row = Rows - 1;
} else if (State == MODE_CMDLINE && confirm_msg != NULL) { } else if ((State & MODE_CMDLINE) && confirm_msg != NULL) {
display_confirm_msg(); // display ":confirm" message again display_confirm_msg(); // display ":confirm" message again
msg_row = Rows - 1; msg_row = Rows - 1;
} else if (State == MODE_EXTERNCMD) { } else if (State == MODE_EXTERNCMD) {

View File

@@ -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 // To keep the code simple, we only allow changing the
// draw mode when the popup menu is not being displayed // draw mode when the popup menu is not being displayed
pum_external = ui_has(kUIPopupmenu) 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 { do {
// Mark the pum as visible already here, // 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; int below_row = cmdline_row;
// wildoptions=pum // wildoptions=pum
if (State == MODE_CMDLINE) { if (State & MODE_CMDLINE) {
pum_win_row = ui_has(kUICmdline) ? 0 : cmdline_row; pum_win_row = ui_has(kUICmdline) ? 0 : cmdline_row;
cursor_col = cmd_startcol; cursor_col = cmd_startcol;
pum_anchor_grid = ui_has(kUICmdline) ? -1 : DEFAULT_GRID_HANDLE; 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 "pum_win_row"
pum_above = true; pum_above = true;
if (State == MODE_CMDLINE) { if (State & MODE_CMDLINE) {
// for cmdline pum, no need for context lines // for cmdline pum, no need for context lines
context_lines = 0; context_lines = 0;
} else { } 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 below "pum_win_row"
pum_above = false; pum_above = false;
if (State == MODE_CMDLINE) { if (State & MODE_CMDLINE) {
// for cmdline pum, no need for context lines // for cmdline pum, no need for context lines
context_lines = 0; context_lines = 0;
} else { } 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. // room the window size will keep changing.
} while (pum_set_selected(selected, redo_count) && ++redo_count <= 2); } 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(); pum_redraw();
} }
@@ -418,15 +418,15 @@ static int *pum_compute_text_attrs(char *text, hlf_T hlf, int user_hlattr)
return NULL; return NULL;
} }
char *leader = State == MODE_CMDLINE ? cmdline_compl_pattern() char *leader = (State & MODE_CMDLINE) ? cmdline_compl_pattern()
: ins_compl_leader(); : ins_compl_leader();
if (leader == NULL || *leader == NUL) { if (leader == NULL || *leader == NUL) {
return NULL; return NULL;
} }
int *attrs = xmalloc(sizeof(int) * (size_t)vim_strsize(text)); int *attrs = xmalloc(sizeof(int) * (size_t)vim_strsize(text));
bool in_fuzzy = State == MODE_CMDLINE ? cmdline_compl_is_fuzzy() bool in_fuzzy = (State & MODE_CMDLINE) ? cmdline_compl_is_fuzzy()
: (get_cot_flags() & kOptCotFlagFuzzy) != 0; : (get_cot_flags() & kOptCotFlagFuzzy) != 0;
size_t leader_len = strlen(leader); size_t leader_len = strlen(leader);
garray_T *ga = NULL; garray_T *ga = NULL;

View File

@@ -185,11 +185,11 @@ void get_mode(char *buf)
int i = 0; int i = 0;
if (State == MODE_HITRETURN || State == MODE_ASKMORE || State == MODE_SETWSIZE if (State == MODE_HITRETURN || State == MODE_ASKMORE || State == MODE_SETWSIZE
|| (State == MODE_CMDLINE && get_cmdline_info()->one_key)) { || ((State & MODE_CMDLINE) && get_cmdline_info()->one_key)) {
buf[i++] = 'r'; buf[i++] = 'r';
if (State == MODE_ASKMORE) { if (State == MODE_ASKMORE) {
buf[i++] = 'm'; buf[i++] = 'm';
} else if (State == MODE_CMDLINE) { } else if (State & MODE_CMDLINE) {
buf[i++] = '?'; buf[i++] = '?';
} }
} else if (State == MODE_EXTERNCMD) { } else if (State == MODE_EXTERNCMD) {

View File

@@ -541,7 +541,7 @@ void ui_flush(void)
cmdline_ui_flush(); cmdline_ui_flush();
if (State != MODE_CMDLINE && curwin->w_floating && curwin->w_config.hide) { if (!(State & MODE_CMDLINE) && curwin->w_floating && curwin->w_config.hide) {
if (!was_busy) { if (!was_busy) {
ui_call_busy_start(); ui_call_busy_start();
was_busy = true; was_busy = true;

View File

@@ -1141,6 +1141,16 @@ describe('cmdline redraw', function()
]]) ]])
command('redraw') command('redraw')
screen:expect_unchanged() screen:expect_unchanged()
command('set keymap=dvorak')
feed('<C-^>')
command('redraw')
screen:expect_unchanged()
feed('<C-^>')
command('set keymap&')
command('redraw')
screen:expect_unchanged()
end) end)
it('substitute confirm prompt does not scroll', function() it('substitute confirm prompt does not scroll', function()

View File

@@ -9587,6 +9587,15 @@ describe('float window', function()
]] ]]
}) })
end end
command('set keymap=dvorak')
feed('<C-^>')
screen:expect_unchanged()
feed('<C-^>')
command('set keymap&')
screen:expect_unchanged()
feed('<ESC>') feed('<ESC>')
-- Show cursor after switching to a normal window (hide=false). -- Show cursor after switching to a normal window (hide=false).

View File

@@ -4130,7 +4130,7 @@ describe('builtin popupmenu', function()
]]) ]])
end end
-- not rightleft on the cmdline -- oldtest: Test_wildmenu_pum_rightleft()
feed('<esc>:sign ') feed('<esc>:sign ')
if multigrid then if multigrid then
screen:expect({ screen:expect({
@@ -4154,9 +4154,8 @@ describe('builtin popupmenu', function()
]], ]],
} }
end end
-- Not rightleft on the cmdline.
-- oldtest: Test_wildmenu_pum_rightleft() feed('<Tab>')
feed('<tab>')
if multigrid then if multigrid then
screen:expect({ screen:expect({
grid = [[ grid = [[
@@ -4195,6 +4194,15 @@ describe('builtin popupmenu', function()
]], ]],
} }
end 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) end)
it('with rightleft vsplits', function() it('with rightleft vsplits', function()

View File

@@ -365,7 +365,7 @@ for _, v in ipairs(ext_keys) do
expect_keys[v] = true expect_keys[v] = true
end end
--- @class test.function.ui.screen.Expect --- @class test.functional.ui.screen.Expect
--- ---
--- Expected screen state (string). Each line represents a screen --- Expected screen state (string). Each line represents a screen
--- row. Last character of each row (typically "|") is stripped. --- row. Last character of each row (typically "|") is stripped.
@@ -460,7 +460,7 @@ end
--- or keyword args (supports more options): --- or keyword args (supports more options):
--- screen:expect({ grid=[[...]], cmdline={...}, condition=function() ... end }) --- screen:expect({ grid=[[...]], cmdline={...}, condition=function() ... end })
--- ---
--- @param expected string|function|test.function.ui.screen.Expect --- @param expected string|function|test.functional.ui.screen.Expect
--- @param attr_ids? table<integer,table<string,any>> --- @param attr_ids? table<integer,table<string,any>>
function Screen:expect(expected, attr_ids, ...) function Screen:expect(expected, attr_ids, ...)
--- @type string, fun() --- @type string, fun()