comparison src/testdir/test_quickfix.vim @ 8932:25c2031e9f9f v7.4.1752

commit https://github.com/vim/vim/commit/c1808d5822ed9534ef7f0fe509b15bee92a5cc28 Author: Bram Moolenaar <Bram@vim.org> Date: Mon Apr 18 20:04:00 2016 +0200 patch 7.4.1752 Problem: When adding to the quickfix list the current position is reset. Solution: Do not reset the position when not needed. (Yegappan Lakshmanan)
author Christian Brabandt <cb@256bit.org>
date Mon, 18 Apr 2016 20:15:05 +0200
parents 7f974075eb8f
children 90f7dc794aa0
comparison
equal deleted inserted replaced
8931:20af5157c7f4 8932:25c2031e9f9f
695 695
696 func Test_cgetexpr_works() 696 func Test_cgetexpr_works()
697 " this must not crash Vim 697 " this must not crash Vim
698 cgetexpr [$x] 698 cgetexpr [$x]
699 endfunc 699 endfunc
700
701 " Tests for the setqflist() and setloclist() functions
702 function SetXlistTests(cchar, bnum)
703 if a:cchar == 'c'
704 let Xsetlist = function('setqflist')
705 let Xgetlist = function('getqflist')
706 let Xnext = 'cnext'
707 else
708 let Xsetlist = function('setloclist', [0])
709 let Xgetlist = function('getloclist', [0])
710 let Xnext = 'lnext'
711 endif
712
713 call Xsetlist([{'bufnr': a:bnum, 'lnum': 1},
714 \ {'bufnr': a:bnum, 'lnum': 2}])
715 let l = Xgetlist()
716 call assert_equal(2, len(l))
717 call assert_equal(2, l[1].lnum)
718
719 exe Xnext
720 call Xsetlist([{'bufnr': a:bnum, 'lnum': 3}], 'a')
721 let l = Xgetlist()
722 call assert_equal(3, len(l))
723 exe Xnext
724 call assert_equal(3, line('.'))
725
726 call Xsetlist([{'bufnr': a:bnum, 'lnum': 3},
727 \ {'bufnr': a:bnum, 'lnum': 4},
728 \ {'bufnr': a:bnum, 'lnum': 5}], 'r')
729 let l = Xgetlist()
730 call assert_equal(3, len(l))
731 call assert_equal(5, l[2].lnum)
732
733 call Xsetlist([])
734 let l = Xgetlist()
735 call assert_equal(0, len(l))
736 endfunction
737
738 function Test_setqflist()
739 new Xtestfile | only
740 let bnum = bufnr('%')
741 call setline(1, range(1,5))
742
743 call SetXlistTests('c', bnum)
744 call SetXlistTests('l', bnum)
745
746 call delete('Xtestfile')
747 endfunction