Mercurial > vim
changeset 24622:ae44ab8824dd v8.2.2850
patch 8.2.2850: recalling commands from history is not tested
Commit: https://github.com/vim/vim/commit/71c6f7a665eb467054fbf319989d97c252af28d2
Author: obcat <obcat@icloud.com>
Date: Thu May 13 20:23:10 2021 +0200
patch 8.2.2850: recalling commands from history is not tested
Problem: Recalling commands from history is not tested.
Solution: Add tests. (closes https://github.com/vim/vim/issues/8194)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Thu, 13 May 2021 20:30:03 +0200 |
parents | 509b22dbcb23 |
children | 99ec3d98043f |
files | src/testdir/test_cmdline.vim src/version.c |
diffstat | 2 files changed, 50 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/src/testdir/test_cmdline.vim +++ b/src/testdir/test_cmdline.vim @@ -1751,4 +1751,52 @@ func Test_wildmenu_dirstack() set wildmenu& 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