fix(insert): pumvisible() guard on smart_return/smart_shift_return (audit follow-up)
CI / cargo fmt --check (push) Successful in 23s
CI / cargo clippy (push) Successful in 22s
CI / cargo test (push) Successful in 28s
CI / editor keymaps (push) Successful in 1m27s

The mappings re-audit confirmed the two new bindings (visual <CR> normalize,
insert <S-CR> multiline item) are correct — column math matches upstream's
s:text_begin, auto-indent handling sound, no parity gaps or regressions.

It flagged one low-severity item shared with the pre-existing smart_return:
neither guarded the completion popup. Upstream maps <CR>/<S-CR> as
`pumvisible() ? '<CR>' : …`. Added that guard to both smart_return and
smart_shift_return (both clients) so a <CR>/<S-CR> accepts the completion
instead of continuing the list when the popup is open.

Left as a documented minor divergence: <S-CR> on an *empty* bullet emits the
aligned no-marker continuation rather than upstream's "blank line above, keep
marker" (niche). Neovim 305, Vim 299/18/21 pass.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-06-03 11:10:07 +00:00
parent 724712121d
commit 03005d0931
3 changed files with 15 additions and 2 deletions
+4
View File
@@ -963,6 +963,9 @@ function M.smart_return()
local cr = tc('<CR>')
local esc = tc('<Esc>')
-- Accept the completion (plain <CR>) when the popup menu is open, like upstream.
if vim.fn.pumvisible() == 1 then return cr end
if is_table_row(line) then
local row = vim.api.nvim_win_get_cursor(0)[1]
return string.format(
@@ -1006,6 +1009,7 @@ end
function M.smart_shift_return()
local line = vim.api.nvim_get_current_line()
local cr = vim.api.nvim_replace_termcodes('<CR>', true, false, true)
if vim.fn.pumvisible() == 1 then return cr end
local indent, marker, after = line:match('^(%s*)([%-%*%#])%s(.*)$')
if not marker then
local n