# HG changeset patch # User Bram Moolenaar # Date 1620930603 -7200 # Node ID ae44ab8824ddb0339fbbdae74f31507329b7b64c # Parent 509b22dbcb23f95f3911a29263dca5df9ce8c54f patch 8.2.2850: recalling commands from history is not tested Commit: https://github.com/vim/vim/commit/71c6f7a665eb467054fbf319989d97c252af28d2 Author: obcat 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) diff --git a/src/testdir/test_cmdline.vim b/src/testdir/test_cmdline.vim --- 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 , , +" , , , , , or . +func Test_recalling_cmdline() + CheckFeature cmdline_hist + + let g:cmdlines = [] + cnoremap (save-cmdline) let g:cmdlines += [getcmdline()] + + let histories = [ + \ {'name': 'cmd', 'enter': ':', 'exit': "\"}, + \ {'name': 'search', 'enter': '/', 'exit': "\"}, + \ {'name': 'expr', 'enter': ":\=", 'exit': "\\"}, + \ {'name': 'input', 'enter': ":call input('')\", 'exit': "\"}, + "\ TODO: {'name': 'debug', ...} + \] + let keypairs = [ + \ {'older': "\", 'newer': "\", 'prefixmatch': v:true}, + \ {'older': "\", 'newer': "\", 'prefixmatch': v:false}, + \ {'older': "\", 'newer': "\", 'prefixmatch': v:false}, + \ {'older': "\", 'newer': "\", '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 .. "\(save-cmdline)", 2) + \ .. repeat(k.newer .. "\(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 (save-cmdline) +endfunc + " vim: shiftwidth=2 sts=2 expandtab diff --git a/src/version.c b/src/version.c --- a/src/version.c +++ b/src/version.c @@ -751,6 +751,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 2850, +/**/ 2849, /**/ 2848,