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
+3
View File
@@ -1268,6 +1268,8 @@ endfunction
" returned string is fed into Vim's input stream after the function
" finishes, keeping the undo block coherent.
function! nuwiki#commands#smart_return() abort
" Accept the completion (plain <CR>) when the popup menu is open, like upstream.
if pumvisible() | return "\<CR>" | endif
let l:line = getline('.')
" `<expr>` runs under textlock, so the function must be side-effect-
" free on the buffer. Buffer-mutating branches return a `<Cmd>:call
@@ -1314,6 +1316,7 @@ endfunction
" new marker, indented to align under the item's text — vimwiki's "multiline
" list item" (`VimwikiReturn 2 2`). Off a list item it's a plain `<CR>`.
function! nuwiki#commands#smart_shift_return() abort
if pumvisible() | return "\<CR>" | endif
let l:line = getline('.')
let l:m = matchlist(l:line, '^\(\s*\)\([-*#]\)\s\(.*\)$')
if empty(l:m)