aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/testdir
diff options
context:
space:
mode:
authorJustin M. Keyes <justinkz@gmail.com>2020-04-26 23:57:37 -0400
committerGitHub <noreply@github.com>2020-04-26 23:57:37 -0400
commit34ad1ea36637845adb14c579587168126d3210e3 (patch)
tree7342478885db7348b3925739f5a0320b48121102 /src/nvim/testdir
parent5f41717838f4cd9d1087e452640ba554500279ab (diff)
parent978a6bcaf2b98b3c89381a3eacf642b4f61db033 (diff)
downloadrneovim-34ad1ea36637845adb14c579587168126d3210e3.tar.gz
rneovim-34ad1ea36637845adb14c579587168126d3210e3.tar.bz2
rneovim-34ad1ea36637845adb14c579587168126d3210e3.zip
Merge #12155 ':ls filter by terminal, lastused'
Diffstat (limited to 'src/nvim/testdir')
-rw-r--r--src/nvim/testdir/test_bufwintabinfo.vim7
-rw-r--r--src/nvim/testdir/test_cmdline.vim46
-rw-r--r--src/nvim/testdir/test_excmd.vim32
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