diff options
| author | Rob Pilling <robpilling@gmail.com> | 2020-03-22 21:40:12 +0000 |
|---|---|---|
| committer | Rob Pilling <robpilling@gmail.com> | 2020-04-21 21:40:22 +0100 |
| commit | 978a6bcaf2b98b3c89381a3eacf642b4f61db033 (patch) | |
| tree | 29f26959683fa1f5b10feed3b086531777d1e9f6 /src/nvim/testdir | |
| parent | 9d59f066cbbe8893559586eee5bfca9378cf6385 (diff) | |
| download | rneovim-978a6bcaf2b98b3c89381a3eacf642b4f61db033.tar.gz rneovim-978a6bcaf2b98b3c89381a3eacf642b4f61db033.tar.bz2 rneovim-978a6bcaf2b98b3c89381a3eacf642b4f61db033.zip | |
vim-patch:8.1.2225: the "last used" info of a buffer is under used
Problem: The "last used" info of a buffer is under used.
Solution: Add "lastused" to getbufinfo(). List buffers sorted by last-used
field. (Andi Massimino, closes vim/vim#4722)
https://github.com/vim/vim/commit/52410575be50d5c40bbe6380159df48cfc382ceb
Diffstat (limited to 'src/nvim/testdir')
| -rw-r--r-- | src/nvim/testdir/test_bufwintabinfo.vim | 7 | ||||
| -rw-r--r-- | src/nvim/testdir/test_cmdline.vim | 46 | ||||
| -rw-r--r-- | src/nvim/testdir/test_excmd.vim | 32 |
3 files changed, 85 insertions, 0 deletions
diff --git a/src/nvim/testdir/test_bufwintabinfo.vim b/src/nvim/testdir/test_bufwintabinfo.vim index 176d49d28e..cb7ab44798 100644 --- a/src/nvim/testdir/test_bufwintabinfo.vim +++ b/src/nvim/testdir/test_bufwintabinfo.vim @@ -149,3 +149,10 @@ func Test_getbufinfo_lines() edit Xfoo bw! endfunc + +function Test_getbufinfo_lastused() + new Xfoo + let info = getbufinfo('Xfoo')[0] + call assert_equal(has_key(info, 'lastused'), 1) + call assert_equal(type(info.lastused), type(0)) +endfunc diff --git a/src/nvim/testdir/test_cmdline.vim b/src/nvim/testdir/test_cmdline.vim index 9c3c33a943..7f1e1f4456 100644 --- a/src/nvim/testdir/test_cmdline.vim +++ b/src/nvim/testdir/test_cmdline.vim @@ -755,3 +755,49 @@ func Test_cmdwin_feedkeys() " This should not generate E488 call feedkeys("q:\<CR>", 'x') endfunc + +func Test_buffers_lastused() + " check that buffers are sorted by time when wildmode has lastused + edit bufc " oldest + + sleep 1200m + enew + edit bufa " middle + + sleep 1200m + enew + edit bufb " newest + + enew + + call assert_equal(['bufc', 'bufa', 'bufb'], + \ getcompletion('', 'buffer')) + + let save_wildmode = &wildmode + set wildmode=full:lastused + + let cap = "\<c-r>=execute('let X=getcmdline()')\<cr>" + call feedkeys(":b \<tab>" .. cap .. "\<esc>", 'xt') + call assert_equal('b bufb', X) + call feedkeys(":b \<tab>\<tab>" .. cap .. "\<esc>", 'xt') + call assert_equal('b bufa', X) + call feedkeys(":b \<tab>\<tab>\<tab>" .. cap .. "\<esc>", 'xt') + call assert_equal('b bufc', X) + enew + + sleep 1200m + edit other + call feedkeys(":b \<tab>" .. cap .. "\<esc>", 'xt') + call assert_equal('b bufb', X) + call feedkeys(":b \<tab>\<tab>" .. cap .. "\<esc>", 'xt') + call assert_equal('b bufa', X) + call feedkeys(":b \<tab>\<tab>\<tab>" .. cap .. "\<esc>", 'xt') + call assert_equal('b bufc', X) + enew + + let &wildmode = save_wildmode + + bwipeout bufa + bwipeout bufb + bwipeout bufc +endfunc diff --git a/src/nvim/testdir/test_excmd.vim b/src/nvim/testdir/test_excmd.vim index f5ce979208..4a027c3864 100644 --- a/src/nvim/testdir/test_excmd.vim +++ b/src/nvim/testdir/test_excmd.vim @@ -8,3 +8,35 @@ func Test_ex_delete() .dl call assert_equal(['a', 'c'], getline(1, 2)) endfunc + +func Test_buffers_lastused() + edit bufc " oldest + + sleep 1200m + edit bufa " middle + + sleep 1200m + edit bufb " newest + + enew + + let ls = split(execute('buffers t', 'silent!'), '\n') + let bufs = [] + for line in ls + let bufs += [split(line, '"\s*')[1:2]] + endfor + + let names = [] + for buf in bufs + if buf[0] !=# '[No Name]' + let names += [buf[0]] + endif + endfor + + call assert_equal(['bufb', 'bufa', 'bufc'], names) + call assert_match('[0-2] seconds ago', bufs[1][1]) + + bwipeout bufa + bwipeout bufb + bwipeout bufc +endfunc |