vim-patch:9.1.1426: completion: register contents not completed

Problem:  CTRL-X CTRL-R only completes individual words from registers,
          making it difficult to insert complete register content.
Solution: Add consecutive CTRL-X CTRL-R support - first press completes
          words, second press completes full register lines, similar to
          CTRL-X CTRL-L and CTRL-X CTRL-P behavior (glepnir).

closes: vim/vim#17395

d5fdfa5c9c

Co-authored-by: glepnir <glephunter@gmail.com>
This commit is contained in:
glepnir
2025-06-03 14:48:53 +08:00
parent ee84518b94
commit eb10852804
6 changed files with 79 additions and 31 deletions

View File

@ -4751,6 +4751,27 @@ func Test_register_completion()
call feedkeys("Sze\<C-X>\<C-R>\<C-R>=string(complete_info(['mode']))\<CR>\<ESC>", "tx")
call assert_equal("zero{'mode': 'register'}", getline(1))
" Test consecutive CTRL-X CTRL-R (adding mode)Add commentMore actions
" First CTRL-X CTRL-R should split into words, second should use full content
let @f = "hello world test complete"
call setline(1, "hel")
call cursor(1, 3)
call feedkeys("a\<C-X>\<C-R>\<C-N>\<Esc>", 'tx')
call assert_equal("hello", getline(1))
" Second consecutive CTRL-X CTRL-R should complete with full content
call setline(1, "hello")
call cursor(1, 5)
call feedkeys("a\<C-X>\<C-R>\<C-X>\<C-R>\<Esc>", 'tx')
call assert_equal("hello world test complete", getline(1))
" Test consecutive completion with multi-line register
let @g = "first line content\nsecond line here\nthird line data"
call setline(1, "first")
call cursor(1, 5)
call feedkeys("a\<C-X>\<C-R>\<C-X>\<C-R>\<Esc>", 'tx')
call assert_equal("first line content", getline(1))
" Clean up
bwipe!
delfunc GetItems