fix(ui2): ENTER may focus pager in insert/terminal mode #38497

fix(ui2): prevent <CR> from focusing pager in insert/terminal mode

Problem:  <CR> in insert/terminal mode can focus pager unexpectedly.
Solution: Don't enter the pager when <CR> is pressed during expanded
          cmdline in insert/terminal mode.
This commit is contained in:
phanium
2026-03-27 01:42:46 +08:00
committed by GitHub
parent 5f9bc7c272
commit ae2829ee35
4 changed files with 24 additions and 6 deletions

View File

@@ -43,7 +43,7 @@
--- Unlike the legacy |hit-enter| prompt, messages exceeding 'cmdheight' are
--- instead "collapsed", followed by a `[+x]` "spill" indicator, where `x`
--- indicates the spilled lines. To see the full messages, do either:
--- - ENTER immediately after a message from interactive |:| cmdline.
--- - ENTER while cmdline is expanded (not in |Insert-mode| and |Terminal-mode|).
--- - |g<| at any time.
local api = vim.api

View File

@@ -517,7 +517,7 @@ local cmd_on_key = function(_, typed)
M.cmd_on_key, M.cmd.ids = nil, {}
-- Check if window was entered and reopen with original config.
local entered = typed == '<CR>'
local entered = typed == '<CR>' and not api.nvim_get_mode().mode:match('[it]')
or typed:find('LeftMouse') and fn.getmousepos().winid == ui.wins.cmd
pcall(api.nvim_win_close, ui.wins.cmd, true)
ui.check_targets()