aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJan Edmund Lazo <jan.lazo@mail.utoronto.ca>2021-05-13 23:56:34 -0400
committerJan Edmund Lazo <jan.lazo@mail.utoronto.ca>2021-05-13 23:57:24 -0400
commit520b925627604a5c3030d4e59dc2caa2f6501736 (patch)
tree0b4c5c29ea304d380fb95db6aed5c2dcd14f1abc /src
parent5110ef9171ac63994a02ce2f215dbae308877b07 (diff)
downloadrneovim-520b925627604a5c3030d4e59dc2caa2f6501736.tar.gz
rneovim-520b925627604a5c3030d4e59dc2caa2f6501736.tar.bz2
rneovim-520b925627604a5c3030d4e59dc2caa2f6501736.zip
vim-patch:8.2.2850: recalling commands from history is not tested
Problem: Recalling commands from history is not tested. Solution: Add tests. (closes vim/vim#8194) https://github.com/vim/vim/commit/71c6f7a665eb467054fbf319989d97c252af28d2
Diffstat (limited to 'src')
-rw-r--r--src/nvim/testdir/test_cmdline.vim48
1 files changed, 48 insertions, 0 deletions
diff --git a/src/nvim/testdir/test_cmdline.vim b/src/nvim/testdir/test_cmdline.vim
index b521a193c4..34126b49fa 100644
--- a/src/nvim/testdir/test_cmdline.vim
+++ b/src/nvim/testdir/test_cmdline.vim
@@ -1072,4 +1072,52 @@ func Test_read_shellcmd()
endif
endfunc
+" Test for recalling newer or older cmdline from history with <Up>, <Down>,
+" <S-Up>, <S-Down>, <PageUp>, <PageDown>, <C-p>, or <C-n>.
+func Test_recalling_cmdline()
+ CheckFeature cmdline_hist
+
+ let g:cmdlines = []
+ cnoremap <Plug>(save-cmdline) <Cmd>let g:cmdlines += [getcmdline()]<CR>
+
+ let histories = [
+ \ {'name': 'cmd', 'enter': ':', 'exit': "\<Esc>"},
+ \ {'name': 'search', 'enter': '/', 'exit': "\<Esc>"},
+ \ {'name': 'expr', 'enter': ":\<C-r>=", 'exit': "\<Esc>\<Esc>"},
+ \ {'name': 'input', 'enter': ":call input('')\<CR>", 'exit': "\<CR>"},
+ "\ TODO: {'name': 'debug', ...}
+ \]
+ let keypairs = [
+ \ {'older': "\<Up>", 'newer': "\<Down>", 'prefixmatch': v:true},
+ \ {'older': "\<S-Up>", 'newer': "\<S-Down>", 'prefixmatch': v:false},
+ \ {'older': "\<PageUp>", 'newer': "\<PageDown>", 'prefixmatch': v:false},
+ \ {'older': "\<C-p>", 'newer': "\<C-n>", 'prefixmatch': v:false},
+ \]
+ let prefix = 'vi'
+ for h in histories
+ call histadd(h.name, 'vim')
+ call histadd(h.name, 'virtue')
+ call histadd(h.name, 'Virgo')
+ call histadd(h.name, 'vogue')
+ call histadd(h.name, 'emacs')
+ for k in keypairs
+ let g:cmdlines = []
+ let keyseqs = h.enter
+ \ .. prefix
+ \ .. repeat(k.older .. "\<Plug>(save-cmdline)", 2)
+ \ .. repeat(k.newer .. "\<Plug>(save-cmdline)", 2)
+ \ .. h.exit
+ call feedkeys(keyseqs, 'xt')
+ call histdel(h.name, -1) " delete the history added by feedkeys above
+ let expect = k.prefixmatch
+ \ ? ['virtue', 'vim', 'virtue', prefix]
+ \ : ['emacs', 'vogue', 'emacs', prefix]
+ call assert_equal(expect, g:cmdlines)
+ endfor
+ endfor
+
+ unlet g:cmdlines
+ cunmap <Plug>(save-cmdline)
+endfunc
+
" vim: shiftwidth=2 sts=2 expandtab