summaryrefslogtreecommitdiff
path: root/src/testdir
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2019-01-11 14:50:06 +0100
committerBram Moolenaar <Bram@vim.org>2019-01-11 14:50:06 +0100
commit5b69c22fd2bf0c0d32aab90ee4c7ef74259d2c4c (patch)
treedcbcdbcaeeba17cdb70d523f6192c65f53716fa8 /src/testdir
parent870ba5f6dce974b6c1c47bf9d3b20db805d10b36 (diff)
downloadvim-git-5b69c22fd2bf0c0d32aab90ee4c7ef74259d2c4c.tar.gz
patch 8.1.0720: cannot easily change the current quickfx list indexv8.1.0720
Problem: Cannot easily change the current quickfx list index. Solution: Add the "idx" argument to setqflist(). (Yegappan Lakshmanan, closes #3701)
Diffstat (limited to 'src/testdir')
-rw-r--r--src/testdir/test_quickfix.vim57
1 files changed, 57 insertions, 0 deletions
diff --git a/src/testdir/test_quickfix.vim b/src/testdir/test_quickfix.vim
index 7fdfc73aa..db2a8e6c5 100644
--- a/src/testdir/test_quickfix.vim
+++ b/src/testdir/test_quickfix.vim
@@ -1811,6 +1811,13 @@ func HistoryTest(cchar)
call g:Xsetlist([], 'f')
let l = split(execute(a:cchar . 'hist'), "\n")
call assert_equal('No entries', l[0])
+
+ " An empty list should still show the stack history
+ call g:Xsetlist([])
+ let res = split(execute(a:cchar . 'hist'), "\n")
+ call assert_equal('> error list 1 of 1; 0 ' . common, res[0])
+
+ call g:Xsetlist([], 'f')
endfunc
func Test_history()
@@ -2068,6 +2075,56 @@ func Test_qf_property()
call Xproperty_tests('l')
endfunc
+" Test for setting the current index in the location/quickfix list
+func Xtest_setqfidx(cchar)
+ call s:setup_commands(a:cchar)
+
+ Xgetexpr "F1:10:1:Line1\nF2:20:2:Line2\nF3:30:3:Line3"
+ Xgetexpr "F4:10:1:Line1\nF5:20:2:Line2\nF6:30:3:Line3"
+ Xgetexpr "F7:10:1:Line1\nF8:20:2:Line2\nF9:30:3:Line3"
+
+ call g:Xsetlist([], 'a', {'nr' : 3, 'idx' : 2})
+ call g:Xsetlist([], 'a', {'nr' : 2, 'idx' : 2})
+ call g:Xsetlist([], 'a', {'nr' : 1, 'idx' : 3})
+ Xolder 2
+ Xopen
+ call assert_equal(3, line('.'))
+ Xnewer
+ call assert_equal(2, line('.'))
+ Xnewer
+ call assert_equal(2, line('.'))
+ " Update the current index with the quickfix window open
+ wincmd w
+ call g:Xsetlist([], 'a', {'nr' : 3, 'idx' : 3})
+ Xopen
+ call assert_equal(3, line('.'))
+ Xclose
+
+ " Set the current index to the last entry
+ call g:Xsetlist([], 'a', {'nr' : 1, 'idx' : '$'})
+ call assert_equal(3, g:Xgetlist({'nr' : 1, 'idx' : 0}).idx)
+ " A large value should set the index to the last index
+ call g:Xsetlist([], 'a', {'nr' : 1, 'idx' : 1})
+ call g:Xsetlist([], 'a', {'nr' : 1, 'idx' : 999})
+ call assert_equal(3, g:Xgetlist({'nr' : 1, 'idx' : 0}).idx)
+ " Invalid index values
+ call g:Xsetlist([], 'a', {'nr' : 1, 'idx' : -1})
+ call assert_equal(3, g:Xgetlist({'nr' : 1, 'idx' : 0}).idx)
+ call g:Xsetlist([], 'a', {'nr' : 1, 'idx' : 0})
+ call assert_equal(3, g:Xgetlist({'nr' : 1, 'idx' : 0}).idx)
+ call g:Xsetlist([], 'a', {'nr' : 1, 'idx' : 'xx'})
+ call assert_equal(3, g:Xgetlist({'nr' : 1, 'idx' : 0}).idx)
+ call assert_fails("call g:Xsetlist([], 'a', {'nr':1, 'idx':[]})", 'E745:')
+
+ call g:Xsetlist([], 'f')
+ new | only
+endfunc
+
+func Test_setqfidx()
+ call Xtest_setqfidx('c')
+ call Xtest_setqfidx('l')
+endfunc
+
" Tests for the QuickFixCmdPre/QuickFixCmdPost autocommands
func QfAutoCmdHandler(loc, cmd)
call add(g:acmds, a:loc . a:cmd)