mirror of
https://github.com/neovim/neovim
synced 2025-07-16 01:01:49 +00:00
vim-patch:9.1.1408: not easily possible to complete from register content (#34198)
Problem: not easily possible to complete from register content
Solution: add register-completion submode using i_CTRL-X_CTRL-R
(glepnir)
closes: vim/vim#17354
0546068aae
This commit is contained in:
@ -124,7 +124,7 @@ describe('completion', function()
|
||||
foo |
|
||||
^ |
|
||||
{1:~ }|*5
|
||||
{5:-- ^X mode (^]^D^E^F^I^K^L^N^O^Ps^U^V^Y)} |
|
||||
{5:-- ^X mode (^]^D^E^F^I^K^L^N^O^P^Rs^U^V^Y)} |
|
||||
]])
|
||||
feed('<C-n>')
|
||||
screen:expect([[
|
||||
|
@ -3519,7 +3519,7 @@ describe('float window', function()
|
||||
|
|
||||
{0:~ }|*7
|
||||
## grid 3
|
||||
{3:-- ^X mode (^]^D^E^F^I^K^L^N^O^Ps^U^V^Y)} |
|
||||
{3:-- ^X mode (^]^D^E^F^I^K^L^N^O^P^Rs^U^V^Y)} |
|
||||
## grid 4
|
||||
{1: }|
|
||||
{2:~ }|*2
|
||||
@ -3543,7 +3543,7 @@ describe('float window', function()
|
||||
{1: } {1:^ } |
|
||||
{2:~ }{0: }{2:~ }{0: }|*2
|
||||
{0:~ }|*5
|
||||
{3:-- ^X mode (^]^D^E^F^I^K^L^N^O^Ps^U^V^Y)} |
|
||||
{3:-- ^X mode (^]^D^E^F^I^K^L^N^O^P^Rs^U^V^Y)} |
|
||||
]],
|
||||
}
|
||||
end
|
||||
|
@ -815,7 +815,7 @@ describe('ui/ext_messages', function()
|
||||
^ |
|
||||
{1:~ }|*2
|
||||
]],
|
||||
showmode = { { '-- ^X mode (^]^D^E^F^I^K^L^N^O^Ps^U^V^Y)', 5, 11 } },
|
||||
showmode = { { '-- ^X mode (^]^D^E^F^I^K^L^N^O^P^Rs^U^V^Y)', 5, 11 } },
|
||||
}
|
||||
|
||||
feed('<c-p>')
|
||||
|
@ -3792,4 +3792,85 @@ func Test_complete_match()
|
||||
delfunc TestComplete
|
||||
endfunc
|
||||
|
||||
func Test_register_completion()
|
||||
let @a = "completion test apple application"
|
||||
let @b = "banana behavior better best"
|
||||
let @c = "complete completion compliment computer"
|
||||
let g:save_reg = ''
|
||||
func GetItems()
|
||||
let g:result = complete_info(['pum_visible'])
|
||||
endfunc
|
||||
|
||||
new
|
||||
call setline(1, "comp")
|
||||
call cursor(1, 4)
|
||||
call feedkeys("a\<C-X>\<C-R>\<C-N>\<C-N>\<Esc>", 'tx')
|
||||
call assert_equal("compliment", getline(1))
|
||||
|
||||
inoremap <buffer><F2> <C-R>=GetItems()<CR>
|
||||
call feedkeys("S\<C-X>\<C-R>\<F2>\<ESC>", 'tx')
|
||||
call assert_equal(1, g:result['pum_visible'])
|
||||
|
||||
call setline(1, "app")
|
||||
call cursor(1, 3)
|
||||
call feedkeys("a\<C-X>\<C-R>\<C-N>\<Esc>", 'tx')
|
||||
call assert_equal("application", getline(1))
|
||||
|
||||
" Test completion with case differences
|
||||
set ignorecase
|
||||
let @e = "TestCase UPPERCASE lowercase"
|
||||
call setline(1, "testc")
|
||||
call cursor(1, 5)
|
||||
call feedkeys("a\<C-X>\<C-R>\<Esc>", 'tx')
|
||||
call assert_equal("TestCase", getline(1))
|
||||
|
||||
" Test clipboard registers if available
|
||||
if has('clipboard_working')
|
||||
let g:save_reg = getreg('*')
|
||||
call setreg('*', "clipboard selection unique words")
|
||||
call setline(1, "uni")
|
||||
call cursor(1, 3)
|
||||
call feedkeys("a\<C-X>\<C-R>\<Esc>", 'tx')
|
||||
call assert_equal("unique", getline(1))
|
||||
call setreg('*', g:save_reg)
|
||||
|
||||
let g:save_reg = getreg('+')
|
||||
call setreg('+', "system clipboard special content")
|
||||
call setline(1, "spe")
|
||||
call cursor(1, 3)
|
||||
call feedkeys("a\<C-X>\<C-R>\<Esc>", 'tx')
|
||||
call assert_equal("special", getline(1))
|
||||
call setreg('+', g:save_reg)
|
||||
|
||||
call setreg('*', g:save_reg)
|
||||
call setreg('a', "normal register")
|
||||
call setreg('*', "clipboard mixed content")
|
||||
call setline(1, "mix")
|
||||
call cursor(1, 3)
|
||||
call feedkeys("a\<C-X>\<C-R>\<Esc>", 'tx')
|
||||
call assert_equal("mixed", getline(1))
|
||||
call setreg('*', g:save_reg)
|
||||
endif
|
||||
|
||||
" Test black hole register should be skipped
|
||||
let @_ = "blackhole content should not appear"
|
||||
call setline(1, "black")
|
||||
call cursor(1, 5)
|
||||
call feedkeys("a\<C-X>\<C-R>\<Esc>", 'tx')
|
||||
call assert_equal("black", getline(1))
|
||||
|
||||
let @1 = "recent yank zero"
|
||||
call setline(1, "ze")
|
||||
call cursor(1, 2)
|
||||
call feedkeys("a\<C-X>\<C-R>\<Esc>", 'tx')
|
||||
call assert_equal("zero", getline(1))
|
||||
|
||||
" Clean up
|
||||
bwipe!
|
||||
delfunc GetItems
|
||||
unlet g:result
|
||||
unlet g:save_reg
|
||||
set ignorecase&
|
||||
endfunc
|
||||
|
||||
" vim: shiftwidth=2 sts=2 expandtab nofoldenable
|
||||
|
Reference in New Issue
Block a user