2021-12-19 00:46:28 -07:00
|
|
|
|
" Test for the quickfix feature.
|
2016-12-13 12:15:10 -07:00
|
|
|
|
|
2020-10-17 08:05:33 -07:00
|
|
|
|
source check.vim
|
2022-11-06 22:37:22 -07:00
|
|
|
|
source vim9.vim
|
2020-10-17 08:05:33 -07:00
|
|
|
|
CheckFeature quickfix
|
2016-12-13 12:15:10 -07:00
|
|
|
|
|
2020-11-28 13:28:57 -07:00
|
|
|
|
source screendump.vim
|
|
|
|
|
|
2016-12-13 12:15:10 -07:00
|
|
|
|
set encoding=utf-8
|
|
|
|
|
|
2017-07-16 08:32:32 -07:00
|
|
|
|
func s:setup_commands(cchar)
|
2016-12-12 13:05:34 -07:00
|
|
|
|
if a:cchar == 'c'
|
|
|
|
|
command! -nargs=* -bang Xlist <mods>clist<bang> <args>
|
|
|
|
|
command! -nargs=* Xgetexpr <mods>cgetexpr <args>
|
2016-12-14 08:55:21 -07:00
|
|
|
|
command! -nargs=* Xaddexpr <mods>caddexpr <args>
|
2018-09-06 20:49:21 -07:00
|
|
|
|
command! -nargs=* -count Xolder <mods><count>colder <args>
|
2016-12-12 13:05:34 -07:00
|
|
|
|
command! -nargs=* Xnewer <mods>cnewer <args>
|
2021-05-20 15:05:39 -07:00
|
|
|
|
command! -nargs=* Xopen <mods> copen <args>
|
2016-12-12 13:05:34 -07:00
|
|
|
|
command! -nargs=* Xwindow <mods>cwindow <args>
|
2016-12-14 13:33:06 -07:00
|
|
|
|
command! -nargs=* Xbottom <mods>cbottom <args>
|
2016-12-12 13:05:34 -07:00
|
|
|
|
command! -nargs=* Xclose <mods>cclose <args>
|
|
|
|
|
command! -nargs=* -bang Xfile <mods>cfile<bang> <args>
|
|
|
|
|
command! -nargs=* Xgetfile <mods>cgetfile <args>
|
|
|
|
|
command! -nargs=* Xaddfile <mods>caddfile <args>
|
|
|
|
|
command! -nargs=* -bang Xbuffer <mods>cbuffer<bang> <args>
|
|
|
|
|
command! -nargs=* Xgetbuffer <mods>cgetbuffer <args>
|
|
|
|
|
command! -nargs=* Xaddbuffer <mods>caddbuffer <args>
|
|
|
|
|
command! -nargs=* Xrewind <mods>crewind <args>
|
2017-12-18 19:37:11 -07:00
|
|
|
|
command! -count -nargs=* -bang Xnext <mods><count>cnext<bang> <args>
|
|
|
|
|
command! -count -nargs=* -bang Xprev <mods><count>cprev<bang> <args>
|
2016-12-12 13:06:02 -07:00
|
|
|
|
command! -nargs=* -bang Xfirst <mods>cfirst<bang> <args>
|
|
|
|
|
command! -nargs=* -bang Xlast <mods>clast<bang> <args>
|
2020-10-12 18:02:36 -07:00
|
|
|
|
command! -count -nargs=* -bang Xnfile <mods><count>cnfile<bang> <args>
|
2016-12-12 13:06:02 -07:00
|
|
|
|
command! -nargs=* -bang Xpfile <mods>cpfile<bang> <args>
|
2016-12-12 13:05:34 -07:00
|
|
|
|
command! -nargs=* Xexpr <mods>cexpr <args>
|
2022-01-01 16:06:09 -07:00
|
|
|
|
command! -count=999 -nargs=* Xvimgrep <mods> <count>vimgrep <args>
|
2021-05-20 15:05:39 -07:00
|
|
|
|
command! -nargs=* Xvimgrepadd <mods> vimgrepadd <args>
|
2016-12-12 13:05:47 -07:00
|
|
|
|
command! -nargs=* Xgrep <mods> grep <args>
|
|
|
|
|
command! -nargs=* Xgrepadd <mods> grepadd <args>
|
|
|
|
|
command! -nargs=* Xhelpgrep helpgrep <args>
|
2019-06-05 19:52:38 -07:00
|
|
|
|
command! -nargs=0 -count Xcc <count>cc
|
2019-09-13 19:16:12 -07:00
|
|
|
|
command! -count=1 -nargs=0 Xbelow <mods><count>cbelow
|
|
|
|
|
command! -count=1 -nargs=0 Xabove <mods><count>cabove
|
2021-01-01 01:32:43 -07:00
|
|
|
|
command! -count=1 -nargs=0 Xbefore <mods><count>cbefore
|
|
|
|
|
command! -count=1 -nargs=0 Xafter <mods><count>cafter
|
2016-12-12 13:05:34 -07:00
|
|
|
|
let g:Xgetlist = function('getqflist')
|
|
|
|
|
let g:Xsetlist = function('setqflist')
|
2017-12-18 12:26:49 -07:00
|
|
|
|
call setqflist([], 'f')
|
2016-12-12 13:05:34 -07:00
|
|
|
|
else
|
|
|
|
|
command! -nargs=* -bang Xlist <mods>llist<bang> <args>
|
|
|
|
|
command! -nargs=* Xgetexpr <mods>lgetexpr <args>
|
2016-12-14 08:55:21 -07:00
|
|
|
|
command! -nargs=* Xaddexpr <mods>laddexpr <args>
|
2018-09-06 20:49:21 -07:00
|
|
|
|
command! -nargs=* -count Xolder <mods><count>lolder <args>
|
2016-12-12 13:05:34 -07:00
|
|
|
|
command! -nargs=* Xnewer <mods>lnewer <args>
|
2021-05-20 15:05:39 -07:00
|
|
|
|
command! -nargs=* Xopen <mods> lopen <args>
|
2016-12-12 13:05:34 -07:00
|
|
|
|
command! -nargs=* Xwindow <mods>lwindow <args>
|
2016-12-14 13:33:06 -07:00
|
|
|
|
command! -nargs=* Xbottom <mods>lbottom <args>
|
2016-12-12 13:05:34 -07:00
|
|
|
|
command! -nargs=* Xclose <mods>lclose <args>
|
|
|
|
|
command! -nargs=* -bang Xfile <mods>lfile<bang> <args>
|
|
|
|
|
command! -nargs=* Xgetfile <mods>lgetfile <args>
|
|
|
|
|
command! -nargs=* Xaddfile <mods>laddfile <args>
|
|
|
|
|
command! -nargs=* -bang Xbuffer <mods>lbuffer<bang> <args>
|
|
|
|
|
command! -nargs=* Xgetbuffer <mods>lgetbuffer <args>
|
|
|
|
|
command! -nargs=* Xaddbuffer <mods>laddbuffer <args>
|
|
|
|
|
command! -nargs=* Xrewind <mods>lrewind <args>
|
2017-12-18 19:37:11 -07:00
|
|
|
|
command! -count -nargs=* -bang Xnext <mods><count>lnext<bang> <args>
|
|
|
|
|
command! -count -nargs=* -bang Xprev <mods><count>lprev<bang> <args>
|
2016-12-12 13:06:02 -07:00
|
|
|
|
command! -nargs=* -bang Xfirst <mods>lfirst<bang> <args>
|
|
|
|
|
command! -nargs=* -bang Xlast <mods>llast<bang> <args>
|
2020-10-12 18:02:36 -07:00
|
|
|
|
command! -count -nargs=* -bang Xnfile <mods><count>lnfile<bang> <args>
|
2016-12-12 13:06:02 -07:00
|
|
|
|
command! -nargs=* -bang Xpfile <mods>lpfile<bang> <args>
|
2016-12-12 13:05:34 -07:00
|
|
|
|
command! -nargs=* Xexpr <mods>lexpr <args>
|
2022-01-01 16:06:09 -07:00
|
|
|
|
command! -count=999 -nargs=* Xvimgrep <mods> <count>lvimgrep <args>
|
2021-05-20 15:05:39 -07:00
|
|
|
|
command! -nargs=* Xvimgrepadd <mods> lvimgrepadd <args>
|
2016-12-12 13:05:47 -07:00
|
|
|
|
command! -nargs=* Xgrep <mods> lgrep <args>
|
|
|
|
|
command! -nargs=* Xgrepadd <mods> lgrepadd <args>
|
|
|
|
|
command! -nargs=* Xhelpgrep lhelpgrep <args>
|
2019-06-05 19:52:38 -07:00
|
|
|
|
command! -nargs=0 -count Xcc <count>ll
|
2019-09-13 19:16:12 -07:00
|
|
|
|
command! -count=1 -nargs=0 Xbelow <mods><count>lbelow
|
|
|
|
|
command! -count=1 -nargs=0 Xabove <mods><count>labove
|
2021-01-01 01:32:43 -07:00
|
|
|
|
command! -count=1 -nargs=0 Xbefore <mods><count>lbefore
|
|
|
|
|
command! -count=1 -nargs=0 Xafter <mods><count>lafter
|
2016-12-12 13:05:34 -07:00
|
|
|
|
let g:Xgetlist = function('getloclist', [0])
|
|
|
|
|
let g:Xsetlist = function('setloclist', [0])
|
2017-12-18 12:26:49 -07:00
|
|
|
|
call setloclist(0, [], 'f')
|
2016-12-12 13:05:34 -07:00
|
|
|
|
endif
|
2017-07-16 08:32:32 -07:00
|
|
|
|
endfunc
|
2016-12-12 13:05:34 -07:00
|
|
|
|
|
2022-08-27 16:22:27 -07:00
|
|
|
|
" This must be run before any error lists are created.
|
|
|
|
|
func Test_AA_cc_no_errors()
|
|
|
|
|
call assert_fails('cc', 'E42:')
|
|
|
|
|
call assert_fails('ll', 'E42:')
|
|
|
|
|
endfunc
|
|
|
|
|
|
2016-12-13 12:15:10 -07:00
|
|
|
|
" Tests for the :clist and :llist commands
|
2017-07-16 08:32:32 -07:00
|
|
|
|
func XlistTests(cchar)
|
2016-12-12 13:05:34 -07:00
|
|
|
|
call s:setup_commands(a:cchar)
|
2016-12-13 12:15:10 -07:00
|
|
|
|
|
2017-12-18 12:26:49 -07:00
|
|
|
|
if a:cchar == 'l'
|
|
|
|
|
call assert_fails('llist', 'E776:')
|
|
|
|
|
endif
|
2016-12-13 12:15:10 -07:00
|
|
|
|
" With an empty list, command should return error
|
2016-12-12 13:05:34 -07:00
|
|
|
|
Xgetexpr []
|
|
|
|
|
silent! Xlist
|
2016-12-13 12:15:10 -07:00
|
|
|
|
call assert_true(v:errmsg ==# 'E42: No Errors')
|
|
|
|
|
|
|
|
|
|
" Populate the list and then try
|
2022-10-12 23:31:10 -07:00
|
|
|
|
let lines =<< trim END
|
|
|
|
|
non-error 1
|
|
|
|
|
Xtestfile1:1:3:Line1
|
|
|
|
|
non-error 2
|
|
|
|
|
Xtestfile2:2:2:Line2
|
|
|
|
|
non-error| 3
|
|
|
|
|
Xtestfile3:3:1:Line3
|
|
|
|
|
END
|
|
|
|
|
Xgetexpr lines
|
2016-12-13 12:15:10 -07:00
|
|
|
|
|
|
|
|
|
" List only valid entries
|
2017-12-17 18:56:01 -07:00
|
|
|
|
let l = split(execute('Xlist', ''), "\n")
|
2016-12-13 12:15:10 -07:00
|
|
|
|
call assert_equal([' 2 Xtestfile1:1 col 3: Line1',
|
|
|
|
|
\ ' 4 Xtestfile2:2 col 2: Line2',
|
|
|
|
|
\ ' 6 Xtestfile3:3 col 1: Line3'], l)
|
|
|
|
|
|
|
|
|
|
" List all the entries
|
2017-12-17 18:56:01 -07:00
|
|
|
|
let l = split(execute('Xlist!', ''), "\n")
|
2016-12-13 12:15:10 -07:00
|
|
|
|
call assert_equal([' 1: non-error 1', ' 2 Xtestfile1:1 col 3: Line1',
|
|
|
|
|
\ ' 3: non-error 2', ' 4 Xtestfile2:2 col 2: Line2',
|
2020-10-05 21:07:40 -07:00
|
|
|
|
\ ' 5: non-error| 3', ' 6 Xtestfile3:3 col 1: Line3'], l)
|
2016-12-13 12:15:10 -07:00
|
|
|
|
|
|
|
|
|
" List a range of errors
|
2017-12-17 18:56:01 -07:00
|
|
|
|
let l = split(execute('Xlist 3,6', ''), "\n")
|
2016-12-13 12:15:10 -07:00
|
|
|
|
call assert_equal([' 4 Xtestfile2:2 col 2: Line2',
|
|
|
|
|
\ ' 6 Xtestfile3:3 col 1: Line3'], l)
|
|
|
|
|
|
2017-12-17 18:56:01 -07:00
|
|
|
|
let l = split(execute('Xlist! 3,4', ''), "\n")
|
2016-12-13 12:15:10 -07:00
|
|
|
|
call assert_equal([' 3: non-error 2', ' 4 Xtestfile2:2 col 2: Line2'], l)
|
|
|
|
|
|
2017-12-17 18:56:01 -07:00
|
|
|
|
let l = split(execute('Xlist -6,-4', ''), "\n")
|
2016-12-13 12:15:10 -07:00
|
|
|
|
call assert_equal([' 2 Xtestfile1:1 col 3: Line1'], l)
|
|
|
|
|
|
2017-12-17 18:56:01 -07:00
|
|
|
|
let l = split(execute('Xlist! -5,-3', ''), "\n")
|
2016-12-13 12:15:10 -07:00
|
|
|
|
call assert_equal([' 2 Xtestfile1:1 col 3: Line1',
|
|
|
|
|
\ ' 3: non-error 2', ' 4 Xtestfile2:2 col 2: Line2'], l)
|
2017-12-17 18:51:51 -07:00
|
|
|
|
|
|
|
|
|
" Test for '+'
|
2017-12-17 18:56:01 -07:00
|
|
|
|
let l = split(execute('Xlist! +2', ''), "\n")
|
2017-12-17 18:51:51 -07:00
|
|
|
|
call assert_equal([' 2 Xtestfile1:1 col 3: Line1',
|
|
|
|
|
\ ' 3: non-error 2', ' 4 Xtestfile2:2 col 2: Line2'], l)
|
2017-12-17 18:56:01 -07:00
|
|
|
|
|
2021-07-31 10:10:44 -07:00
|
|
|
|
" Ranged entries
|
|
|
|
|
call g:Xsetlist([{'lnum':10,'text':'Line1'},
|
|
|
|
|
\ {'lnum':20,'col':10,'text':'Line2'},
|
|
|
|
|
\ {'lnum':30,'col':15,'end_col':20,'text':'Line3'},
|
|
|
|
|
\ {'lnum':40,'end_lnum':45,'text':'Line4'},
|
|
|
|
|
\ {'lnum':50,'end_lnum':55,'col':15,'text':'Line5'},
|
|
|
|
|
\ {'lnum':60,'end_lnum':65,'col':25,'end_col':35,'text':'Line6'}])
|
|
|
|
|
let l = split(execute('Xlist', ""), "\n")
|
|
|
|
|
call assert_equal([' 1:10: Line1',
|
|
|
|
|
\ ' 2:20 col 10: Line2',
|
|
|
|
|
\ ' 3:30 col 15-20: Line3',
|
|
|
|
|
\ ' 4:40-45: Line4',
|
|
|
|
|
\ ' 5:50-55 col 15: Line5',
|
|
|
|
|
\ ' 6:60-65 col 25-35: Line6'], l)
|
|
|
|
|
|
2017-12-17 18:56:01 -07:00
|
|
|
|
" Different types of errors
|
|
|
|
|
call g:Xsetlist([{'lnum':10,'col':5,'type':'W', 'text':'Warning','nr':11},
|
|
|
|
|
\ {'lnum':20,'col':10,'type':'e','text':'Error','nr':22},
|
|
|
|
|
\ {'lnum':30,'col':15,'type':'i','text':'Info','nr':33},
|
|
|
|
|
\ {'lnum':40,'col':20,'type':'x', 'text':'Other','nr':44},
|
|
|
|
|
\ {'lnum':50,'col':25,'type':"\<C-A>",'text':'one','nr':55}])
|
|
|
|
|
let l = split(execute('Xlist', ""), "\n")
|
|
|
|
|
call assert_equal([' 1:10 col 5 warning 11: Warning',
|
|
|
|
|
\ ' 2:20 col 10 error 22: Error',
|
|
|
|
|
\ ' 3:30 col 15 info 33: Info',
|
|
|
|
|
\ ' 4:40 col 20 x 44: Other',
|
|
|
|
|
\ ' 5:50 col 25 55: one'], l)
|
|
|
|
|
|
2019-03-31 17:34:06 -07:00
|
|
|
|
" Test for module names, one needs to explicitly set `'valid':v:true` so
|
|
|
|
|
call g:Xsetlist([
|
|
|
|
|
\ {'lnum':10,'col':5,'type':'W','module':'Data.Text','text':'ModuleWarning','nr':11,'valid':v:true},
|
|
|
|
|
\ {'lnum':20,'col':10,'type':'W','module':'Data.Text','filename':'Data/Text.hs','text':'ModuleWarning','nr':22,'valid':v:true},
|
|
|
|
|
\ {'lnum':30,'col':15,'type':'W','filename':'Data/Text.hs','text':'FileWarning','nr':33,'valid':v:true}])
|
|
|
|
|
let l = split(execute('Xlist', ""), "\n")
|
|
|
|
|
call assert_equal([' 1 Data.Text:10 col 5 warning 11: ModuleWarning',
|
2022-02-14 01:17:11 -07:00
|
|
|
|
\ ' 2 Data.Text:20 col 10 warning 22: ModuleWarning',
|
|
|
|
|
\ ' 3 Data/Text.hs:30 col 15 warning 33: FileWarning'], l)
|
2019-03-31 17:34:06 -07:00
|
|
|
|
|
2022-07-28 04:49:18 -07:00
|
|
|
|
" Very long line should be displayed.
|
|
|
|
|
let text = 'Line' .. repeat('1234567890', 130)
|
|
|
|
|
let lines = ['Xtestfile9:2:9:' .. text]
|
|
|
|
|
Xgetexpr lines
|
|
|
|
|
|
|
|
|
|
let l = split(execute('Xlist', ''), "\n")
|
|
|
|
|
call assert_equal([' 1 Xtestfile9:2 col 9: ' .. text] , l)
|
|
|
|
|
|
2021-05-20 15:05:39 -07:00
|
|
|
|
" For help entries in the quickfix list, only the filename without directory
|
|
|
|
|
" should be displayed
|
|
|
|
|
Xhelpgrep setqflist()
|
|
|
|
|
let l = split(execute('Xlist 1', ''), "\n")
|
|
|
|
|
call assert_match('^ 1 [^\\/]\{-}:', l[0])
|
|
|
|
|
|
2017-12-17 18:56:01 -07:00
|
|
|
|
" Error cases
|
|
|
|
|
call assert_fails('Xlist abc', 'E488:')
|
2017-07-16 08:32:32 -07:00
|
|
|
|
endfunc
|
2016-12-13 12:15:10 -07:00
|
|
|
|
|
2017-07-16 08:32:32 -07:00
|
|
|
|
func Test_clist()
|
2016-12-13 12:15:10 -07:00
|
|
|
|
call XlistTests('c')
|
|
|
|
|
call XlistTests('l')
|
2017-07-16 08:32:32 -07:00
|
|
|
|
endfunc
|
2016-12-13 12:15:10 -07:00
|
|
|
|
|
|
|
|
|
" Tests for the :colder, :cnewer, :lolder and :lnewer commands
|
|
|
|
|
" Note that this test assumes that a quickfix/location list is
|
|
|
|
|
" already set by the caller.
|
2017-07-16 08:32:32 -07:00
|
|
|
|
func XageTests(cchar)
|
2016-12-12 13:05:34 -07:00
|
|
|
|
call s:setup_commands(a:cchar)
|
2016-12-13 12:15:10 -07:00
|
|
|
|
|
2019-09-17 14:01:52 -07:00
|
|
|
|
if a:cchar == 'l'
|
|
|
|
|
" No location list for the current window
|
|
|
|
|
call assert_fails('lolder', 'E776:')
|
|
|
|
|
call assert_fails('lnewer', 'E776:')
|
|
|
|
|
endif
|
|
|
|
|
|
2018-02-03 04:11:07 -07:00
|
|
|
|
let list = [{'bufnr': bufnr('%'), 'lnum': 1}]
|
2017-12-18 12:26:49 -07:00
|
|
|
|
call g:Xsetlist(list)
|
|
|
|
|
|
2016-12-13 12:15:10 -07:00
|
|
|
|
" Jumping to a non existent list should return error
|
2016-12-12 13:05:34 -07:00
|
|
|
|
silent! Xolder 99
|
2016-12-13 12:15:10 -07:00
|
|
|
|
call assert_true(v:errmsg ==# 'E380: At bottom of quickfix stack')
|
|
|
|
|
|
2016-12-12 13:05:34 -07:00
|
|
|
|
silent! Xnewer 99
|
2016-12-13 12:15:10 -07:00
|
|
|
|
call assert_true(v:errmsg ==# 'E381: At top of quickfix stack')
|
|
|
|
|
|
|
|
|
|
" Add three quickfix/location lists
|
2016-12-12 13:05:34 -07:00
|
|
|
|
Xgetexpr ['Xtestfile1:1:3:Line1']
|
|
|
|
|
Xgetexpr ['Xtestfile2:2:2:Line2']
|
|
|
|
|
Xgetexpr ['Xtestfile3:3:1:Line3']
|
2016-12-13 12:15:10 -07:00
|
|
|
|
|
|
|
|
|
" Go back two lists
|
2016-12-12 13:05:34 -07:00
|
|
|
|
Xolder
|
|
|
|
|
let l = g:Xgetlist()
|
2016-12-13 12:15:10 -07:00
|
|
|
|
call assert_equal('Line2', l[0].text)
|
|
|
|
|
|
|
|
|
|
" Go forward two lists
|
2016-12-12 13:05:34 -07:00
|
|
|
|
Xnewer
|
|
|
|
|
let l = g:Xgetlist()
|
2016-12-13 12:15:10 -07:00
|
|
|
|
call assert_equal('Line3', l[0].text)
|
|
|
|
|
|
|
|
|
|
" Test for the optional count argument
|
2016-12-12 13:05:34 -07:00
|
|
|
|
Xolder 2
|
|
|
|
|
let l = g:Xgetlist()
|
2016-12-13 12:15:10 -07:00
|
|
|
|
call assert_equal('Line1', l[0].text)
|
|
|
|
|
|
2016-12-12 13:05:34 -07:00
|
|
|
|
Xnewer 2
|
|
|
|
|
let l = g:Xgetlist()
|
2016-12-13 12:15:10 -07:00
|
|
|
|
call assert_equal('Line3', l[0].text)
|
2017-07-16 08:32:32 -07:00
|
|
|
|
endfunc
|
2016-12-13 12:15:10 -07:00
|
|
|
|
|
2017-07-16 08:32:32 -07:00
|
|
|
|
func Test_cage()
|
2016-12-13 12:15:10 -07:00
|
|
|
|
call XageTests('c')
|
|
|
|
|
call XageTests('l')
|
2017-07-16 08:32:32 -07:00
|
|
|
|
endfunc
|
2016-12-13 12:15:10 -07:00
|
|
|
|
|
|
|
|
|
" Tests for the :cwindow, :lwindow :cclose, :lclose, :copen and :lopen
|
|
|
|
|
" commands
|
2017-07-16 08:32:32 -07:00
|
|
|
|
func XwindowTests(cchar)
|
2016-12-12 13:05:34 -07:00
|
|
|
|
call s:setup_commands(a:cchar)
|
2016-12-13 12:15:10 -07:00
|
|
|
|
|
2017-12-18 12:26:49 -07:00
|
|
|
|
" Opening the location list window without any errors should fail
|
|
|
|
|
if a:cchar == 'l'
|
|
|
|
|
call assert_fails('lopen', 'E776:')
|
2022-10-12 19:13:17 -07:00
|
|
|
|
call assert_fails('lwindow', 'E776:')
|
2017-12-18 12:26:49 -07:00
|
|
|
|
endif
|
|
|
|
|
|
2016-12-13 12:15:10 -07:00
|
|
|
|
" Create a list with no valid entries
|
2016-12-12 13:05:34 -07:00
|
|
|
|
Xgetexpr ['non-error 1', 'non-error 2', 'non-error 3']
|
2016-12-13 12:15:10 -07:00
|
|
|
|
|
|
|
|
|
" Quickfix/Location window should not open with no valid errors
|
2016-12-12 13:05:34 -07:00
|
|
|
|
Xwindow
|
2016-12-13 12:15:10 -07:00
|
|
|
|
call assert_true(winnr('$') == 1)
|
|
|
|
|
|
|
|
|
|
" Create a list with valid entries
|
2022-10-12 23:31:10 -07:00
|
|
|
|
let lines =<< trim END
|
|
|
|
|
Xtestfile1:1:3:Line1
|
|
|
|
|
Xtestfile2:2:2:Line2
|
|
|
|
|
Xtestfile3:3:1:Line3
|
|
|
|
|
END
|
|
|
|
|
Xgetexpr lines
|
2016-12-13 12:15:10 -07:00
|
|
|
|
|
|
|
|
|
" Open the window
|
2016-12-12 13:05:34 -07:00
|
|
|
|
Xwindow
|
2016-12-13 12:15:10 -07:00
|
|
|
|
call assert_true(winnr('$') == 2 && winnr() == 2 &&
|
|
|
|
|
\ getline('.') ==# 'Xtestfile1|1 col 3| Line1')
|
2016-12-14 13:33:06 -07:00
|
|
|
|
redraw!
|
2016-12-13 12:15:10 -07:00
|
|
|
|
|
|
|
|
|
" Close the window
|
2016-12-12 13:05:34 -07:00
|
|
|
|
Xclose
|
2016-12-13 12:15:10 -07:00
|
|
|
|
call assert_true(winnr('$') == 1)
|
|
|
|
|
|
|
|
|
|
" Create a list with no valid entries
|
2016-12-12 13:05:34 -07:00
|
|
|
|
Xgetexpr ['non-error 1', 'non-error 2', 'non-error 3']
|
2016-12-13 12:15:10 -07:00
|
|
|
|
|
|
|
|
|
" Open the window
|
2016-12-12 13:05:34 -07:00
|
|
|
|
Xopen 5
|
2016-12-13 12:15:10 -07:00
|
|
|
|
call assert_true(winnr('$') == 2 && getline('.') ==# '|| non-error 1'
|
2021-05-20 17:33:31 -07:00
|
|
|
|
\ && winheight(0) == 5)
|
2016-12-13 12:15:10 -07:00
|
|
|
|
|
|
|
|
|
" Opening the window again, should move the cursor to that window
|
|
|
|
|
wincmd t
|
2016-12-12 13:05:34 -07:00
|
|
|
|
Xopen 7
|
2016-12-13 12:15:10 -07:00
|
|
|
|
call assert_true(winnr('$') == 2 && winnr() == 2 &&
|
2021-05-20 17:33:31 -07:00
|
|
|
|
\ winheight(0) == 7 &&
|
2016-12-13 12:15:10 -07:00
|
|
|
|
\ getline('.') ==# '|| non-error 1')
|
|
|
|
|
|
2021-01-01 11:10:08 -07:00
|
|
|
|
" :cnext in quickfix window should move to the next entry
|
|
|
|
|
Xnext
|
|
|
|
|
call assert_equal(2, g:Xgetlist({'idx' : 0}).idx)
|
2016-12-13 12:15:10 -07:00
|
|
|
|
|
|
|
|
|
" Calling cwindow should close the quickfix window with no valid errors
|
2016-12-12 13:05:34 -07:00
|
|
|
|
Xwindow
|
2016-12-13 12:15:10 -07:00
|
|
|
|
call assert_true(winnr('$') == 1)
|
2017-12-18 12:26:49 -07:00
|
|
|
|
|
2021-05-20 15:05:39 -07:00
|
|
|
|
" Specifying the width should adjust the width for a vertically split
|
|
|
|
|
" quickfix window.
|
|
|
|
|
vert Xopen
|
|
|
|
|
call assert_equal(10, winwidth(0))
|
|
|
|
|
vert Xopen 12
|
|
|
|
|
call assert_equal(12, winwidth(0))
|
|
|
|
|
Xclose
|
|
|
|
|
|
2022-07-15 20:34:19 -07:00
|
|
|
|
" Horizontally or vertically splitting the quickfix window should create a
|
|
|
|
|
" normal window/buffer
|
|
|
|
|
Xopen
|
|
|
|
|
wincmd s
|
|
|
|
|
call assert_equal(0, getwininfo(win_getid())[0].quickfix)
|
|
|
|
|
call assert_equal(0, getwininfo(win_getid())[0].loclist)
|
|
|
|
|
call assert_notequal('quickfix', &buftype)
|
|
|
|
|
close
|
|
|
|
|
Xopen
|
|
|
|
|
wincmd v
|
|
|
|
|
call assert_equal(0, getwininfo(win_getid())[0].quickfix)
|
|
|
|
|
call assert_equal(0, getwininfo(win_getid())[0].loclist)
|
|
|
|
|
call assert_notequal('quickfix', &buftype)
|
|
|
|
|
close
|
|
|
|
|
Xopen
|
|
|
|
|
Xclose
|
|
|
|
|
|
2017-12-18 12:26:49 -07:00
|
|
|
|
if a:cchar == 'c'
|
|
|
|
|
" Opening the quickfix window in multiple tab pages should reuse the
|
|
|
|
|
" quickfix buffer
|
2022-10-12 23:31:10 -07:00
|
|
|
|
let lines =<< trim END
|
|
|
|
|
Xtestfile1:1:3:Line1
|
|
|
|
|
Xtestfile2:2:2:Line2
|
|
|
|
|
Xtestfile3:3:1:Line3
|
|
|
|
|
END
|
|
|
|
|
Xgetexpr lines
|
2017-12-18 12:26:49 -07:00
|
|
|
|
Xopen
|
|
|
|
|
let qfbufnum = bufnr('%')
|
|
|
|
|
tabnew
|
|
|
|
|
Xopen
|
|
|
|
|
call assert_equal(qfbufnum, bufnr('%'))
|
|
|
|
|
new | only | tabonly
|
|
|
|
|
endif
|
2017-07-16 08:32:32 -07:00
|
|
|
|
endfunc
|
2016-12-13 12:15:10 -07:00
|
|
|
|
|
2017-07-16 08:32:32 -07:00
|
|
|
|
func Test_cwindow()
|
2016-12-13 12:15:10 -07:00
|
|
|
|
call XwindowTests('c')
|
|
|
|
|
call XwindowTests('l')
|
2017-07-16 08:32:32 -07:00
|
|
|
|
endfunc
|
2016-12-13 12:15:10 -07:00
|
|
|
|
|
2019-10-27 08:28:13 -07:00
|
|
|
|
func Test_copenHeight()
|
|
|
|
|
copen
|
|
|
|
|
wincmd H
|
|
|
|
|
let height = winheight(0)
|
|
|
|
|
copen 10
|
|
|
|
|
call assert_equal(height, winheight(0))
|
|
|
|
|
quit
|
|
|
|
|
endfunc
|
|
|
|
|
|
2019-10-27 08:31:38 -07:00
|
|
|
|
func Test_copenHeight_tabline()
|
|
|
|
|
set tabline=foo showtabline=2
|
|
|
|
|
copen
|
|
|
|
|
wincmd H
|
|
|
|
|
let height = winheight(0)
|
|
|
|
|
copen 10
|
|
|
|
|
call assert_equal(height, winheight(0))
|
|
|
|
|
quit
|
|
|
|
|
set tabline& showtabline&
|
|
|
|
|
endfunc
|
|
|
|
|
|
2016-12-13 12:15:10 -07:00
|
|
|
|
" Tests for the :cfile, :lfile, :caddfile, :laddfile, :cgetfile and :lgetfile
|
|
|
|
|
" commands.
|
2017-07-16 08:32:32 -07:00
|
|
|
|
func XfileTests(cchar)
|
2016-12-12 13:05:34 -07:00
|
|
|
|
call s:setup_commands(a:cchar)
|
2016-12-13 12:15:10 -07:00
|
|
|
|
|
2022-10-12 23:31:10 -07:00
|
|
|
|
let lines =<< trim END
|
|
|
|
|
Xtestfile1:700:10:Line 700
|
|
|
|
|
Xtestfile2:800:15:Line 800
|
|
|
|
|
END
|
|
|
|
|
call writefile(lines, 'Xqftestfile1')
|
2016-12-13 12:15:10 -07:00
|
|
|
|
|
|
|
|
|
enew!
|
2016-12-12 13:05:34 -07:00
|
|
|
|
Xfile Xqftestfile1
|
|
|
|
|
let l = g:Xgetlist()
|
2016-12-13 12:15:10 -07:00
|
|
|
|
call assert_true(len(l) == 2 &&
|
|
|
|
|
\ l[0].lnum == 700 && l[0].col == 10 && l[0].text ==# 'Line 700' &&
|
|
|
|
|
\ l[1].lnum == 800 && l[1].col == 15 && l[1].text ==# 'Line 800')
|
|
|
|
|
|
2016-12-12 13:05:47 -07:00
|
|
|
|
" Test with a non existent file
|
|
|
|
|
call assert_fails('Xfile non_existent_file', 'E40')
|
|
|
|
|
|
2016-12-13 12:15:10 -07:00
|
|
|
|
" Run cfile/lfile from a modified buffer
|
|
|
|
|
enew!
|
|
|
|
|
silent! put ='Quickfix'
|
2016-12-12 13:05:34 -07:00
|
|
|
|
silent! Xfile Xqftestfile1
|
2016-12-13 12:15:10 -07:00
|
|
|
|
call assert_true(v:errmsg ==# 'E37: No write since last change (add ! to override)')
|
|
|
|
|
|
|
|
|
|
call writefile(['Xtestfile3:900:30:Line 900'], 'Xqftestfile1')
|
2016-12-12 13:05:34 -07:00
|
|
|
|
Xaddfile Xqftestfile1
|
|
|
|
|
let l = g:Xgetlist()
|
2016-12-13 12:15:10 -07:00
|
|
|
|
call assert_true(len(l) == 3 &&
|
|
|
|
|
\ l[2].lnum == 900 && l[2].col == 30 && l[2].text ==# 'Line 900')
|
|
|
|
|
|
2022-10-12 23:31:10 -07:00
|
|
|
|
let lines =<< trim END
|
|
|
|
|
Xtestfile1:222:77:Line 222
|
|
|
|
|
Xtestfile2:333:88:Line 333
|
|
|
|
|
END
|
|
|
|
|
call writefile(lines, 'Xqftestfile1')
|
2016-12-13 12:15:10 -07:00
|
|
|
|
|
|
|
|
|
enew!
|
2016-12-12 13:05:34 -07:00
|
|
|
|
Xgetfile Xqftestfile1
|
|
|
|
|
let l = g:Xgetlist()
|
2016-12-13 12:15:10 -07:00
|
|
|
|
call assert_true(len(l) == 2 &&
|
|
|
|
|
\ l[0].lnum == 222 && l[0].col == 77 && l[0].text ==# 'Line 222' &&
|
|
|
|
|
\ l[1].lnum == 333 && l[1].col == 88 && l[1].text ==# 'Line 333')
|
|
|
|
|
|
2021-05-20 15:49:33 -07:00
|
|
|
|
" Test for a file with a long line and without a newline at the end
|
|
|
|
|
let text = repeat('x', 1024)
|
|
|
|
|
let t = 'a.txt:18:' . text
|
|
|
|
|
call writefile([t], 'Xqftestfile1', 'b')
|
|
|
|
|
silent! Xfile Xqftestfile1
|
|
|
|
|
call assert_equal(text, g:Xgetlist()[0].text)
|
|
|
|
|
|
2016-12-13 12:15:10 -07:00
|
|
|
|
call delete('Xqftestfile1')
|
2017-07-16 08:32:32 -07:00
|
|
|
|
endfunc
|
2016-12-13 12:15:10 -07:00
|
|
|
|
|
2017-07-16 08:32:32 -07:00
|
|
|
|
func Test_cfile()
|
2016-12-13 12:15:10 -07:00
|
|
|
|
call XfileTests('c')
|
|
|
|
|
call XfileTests('l')
|
2017-07-16 08:32:32 -07:00
|
|
|
|
endfunc
|
2016-12-13 12:15:10 -07:00
|
|
|
|
|
|
|
|
|
" Tests for the :cbuffer, :lbuffer, :caddbuffer, :laddbuffer, :cgetbuffer and
|
|
|
|
|
" :lgetbuffer commands.
|
2017-07-16 08:32:32 -07:00
|
|
|
|
func XbufferTests(cchar)
|
2016-12-12 13:05:34 -07:00
|
|
|
|
call s:setup_commands(a:cchar)
|
2016-12-13 12:15:10 -07:00
|
|
|
|
|
|
|
|
|
enew!
|
2022-10-12 23:31:10 -07:00
|
|
|
|
let lines =<< trim END
|
|
|
|
|
Xtestfile7:700:10:Line 700
|
|
|
|
|
Xtestfile8:800:15:Line 800
|
|
|
|
|
END
|
|
|
|
|
silent! call setline(1, lines)
|
2016-12-12 13:05:34 -07:00
|
|
|
|
Xbuffer!
|
|
|
|
|
let l = g:Xgetlist()
|
2016-12-13 12:15:10 -07:00
|
|
|
|
call assert_true(len(l) == 2 &&
|
|
|
|
|
\ l[0].lnum == 700 && l[0].col == 10 && l[0].text ==# 'Line 700' &&
|
|
|
|
|
\ l[1].lnum == 800 && l[1].col == 15 && l[1].text ==# 'Line 800')
|
|
|
|
|
|
|
|
|
|
enew!
|
2022-10-12 23:31:10 -07:00
|
|
|
|
let lines =<< trim END
|
|
|
|
|
Xtestfile9:900:55:Line 900
|
|
|
|
|
Xtestfile10:950:66:Line 950
|
|
|
|
|
END
|
|
|
|
|
silent! call setline(1, lines)
|
2016-12-12 13:05:34 -07:00
|
|
|
|
Xgetbuffer
|
|
|
|
|
let l = g:Xgetlist()
|
2016-12-13 12:15:10 -07:00
|
|
|
|
call assert_true(len(l) == 2 &&
|
|
|
|
|
\ l[0].lnum == 900 && l[0].col == 55 && l[0].text ==# 'Line 900' &&
|
|
|
|
|
\ l[1].lnum == 950 && l[1].col == 66 && l[1].text ==# 'Line 950')
|
|
|
|
|
|
|
|
|
|
enew!
|
2022-10-12 23:31:10 -07:00
|
|
|
|
let lines =<< trim END
|
|
|
|
|
Xtestfile11:700:20:Line 700
|
|
|
|
|
Xtestfile12:750:25:Line 750
|
|
|
|
|
END
|
|
|
|
|
silent! call setline(1, lines)
|
2016-12-12 13:05:34 -07:00
|
|
|
|
Xaddbuffer
|
|
|
|
|
let l = g:Xgetlist()
|
2016-12-13 12:15:10 -07:00
|
|
|
|
call assert_true(len(l) == 4 &&
|
|
|
|
|
\ l[1].lnum == 950 && l[1].col == 66 && l[1].text ==# 'Line 950' &&
|
|
|
|
|
\ l[2].lnum == 700 && l[2].col == 20 && l[2].text ==# 'Line 700' &&
|
|
|
|
|
\ l[3].lnum == 750 && l[3].col == 25 && l[3].text ==# 'Line 750')
|
2016-12-12 13:05:29 -07:00
|
|
|
|
enew!
|
2016-12-13 12:15:10 -07:00
|
|
|
|
|
2017-12-17 18:56:01 -07:00
|
|
|
|
" Check for invalid buffer
|
|
|
|
|
call assert_fails('Xbuffer 199', 'E474:')
|
|
|
|
|
|
|
|
|
|
" Check for unloaded buffer
|
|
|
|
|
edit Xtestfile1
|
|
|
|
|
let bnr = bufnr('%')
|
|
|
|
|
enew!
|
|
|
|
|
call assert_fails('Xbuffer ' . bnr, 'E681:')
|
|
|
|
|
|
|
|
|
|
" Check for invalid range
|
|
|
|
|
" Using Xbuffer will not run the range check in the cbuffer/lbuffer
|
|
|
|
|
" commands. So directly call the commands.
|
|
|
|
|
if (a:cchar == 'c')
|
|
|
|
|
call assert_fails('900,999cbuffer', 'E16:')
|
|
|
|
|
else
|
|
|
|
|
call assert_fails('900,999lbuffer', 'E16:')
|
|
|
|
|
endif
|
2017-07-16 08:32:32 -07:00
|
|
|
|
endfunc
|
2016-12-13 12:15:10 -07:00
|
|
|
|
|
2017-07-16 08:32:32 -07:00
|
|
|
|
func Test_cbuffer()
|
2016-12-13 12:15:10 -07:00
|
|
|
|
call XbufferTests('c')
|
|
|
|
|
call XbufferTests('l')
|
2017-07-16 08:32:32 -07:00
|
|
|
|
endfunc
|
2016-12-13 12:15:10 -07:00
|
|
|
|
|
2017-07-16 08:32:32 -07:00
|
|
|
|
func XexprTests(cchar)
|
2016-12-12 13:06:02 -07:00
|
|
|
|
call s:setup_commands(a:cchar)
|
|
|
|
|
|
|
|
|
|
call assert_fails('Xexpr 10', 'E777:')
|
2017-07-16 08:32:32 -07:00
|
|
|
|
endfunc
|
2016-12-12 13:06:02 -07:00
|
|
|
|
|
2017-07-16 08:32:32 -07:00
|
|
|
|
func Test_cexpr()
|
2016-12-12 13:06:02 -07:00
|
|
|
|
call XexprTests('c')
|
|
|
|
|
call XexprTests('l')
|
2017-07-16 08:32:32 -07:00
|
|
|
|
endfunc
|
2016-12-12 13:06:02 -07:00
|
|
|
|
|
|
|
|
|
" Tests for :cnext, :cprev, :cfirst, :clast commands
|
2017-07-16 08:32:32 -07:00
|
|
|
|
func Xtest_browse(cchar)
|
2016-12-12 13:06:02 -07:00
|
|
|
|
call s:setup_commands(a:cchar)
|
|
|
|
|
|
2019-06-05 19:52:38 -07:00
|
|
|
|
call g:Xsetlist([], 'f')
|
2017-12-18 12:26:49 -07:00
|
|
|
|
" Jumping to first or next location list entry without any error should
|
|
|
|
|
" result in failure
|
2019-06-05 19:52:38 -07:00
|
|
|
|
if a:cchar == 'c'
|
|
|
|
|
let err = 'E42:'
|
2021-01-01 11:10:08 -07:00
|
|
|
|
let cmd = '$cc'
|
2019-06-05 19:52:38 -07:00
|
|
|
|
else
|
|
|
|
|
let err = 'E776:'
|
2021-01-01 11:10:08 -07:00
|
|
|
|
let cmd = '$ll'
|
2017-12-18 12:26:49 -07:00
|
|
|
|
endif
|
2019-06-05 19:52:38 -07:00
|
|
|
|
call assert_fails('Xnext', err)
|
|
|
|
|
call assert_fails('Xprev', err)
|
|
|
|
|
call assert_fails('Xnfile', err)
|
|
|
|
|
call assert_fails('Xpfile', err)
|
2021-01-01 11:10:08 -07:00
|
|
|
|
call assert_fails(cmd, err)
|
|
|
|
|
|
|
|
|
|
Xexpr ''
|
|
|
|
|
call assert_fails(cmd, 'E42:')
|
2017-12-18 12:26:49 -07:00
|
|
|
|
|
2016-12-12 13:06:02 -07:00
|
|
|
|
call s:create_test_file('Xqftestfile1')
|
|
|
|
|
call s:create_test_file('Xqftestfile2')
|
|
|
|
|
|
2022-10-12 23:31:10 -07:00
|
|
|
|
let lines =<< trim END
|
|
|
|
|
Xqftestfile1:5:Line5
|
|
|
|
|
Xqftestfile1:6:Line6
|
|
|
|
|
Xqftestfile2:10:Line10
|
|
|
|
|
Xqftestfile2:11:Line11
|
|
|
|
|
RegularLine1
|
|
|
|
|
RegularLine2
|
|
|
|
|
END
|
|
|
|
|
Xgetexpr lines
|
2016-12-12 13:06:02 -07:00
|
|
|
|
|
|
|
|
|
Xfirst
|
2022-07-11 23:45:36 -07:00
|
|
|
|
call assert_fails('-5Xcc', 'E16:')
|
2016-12-12 13:06:02 -07:00
|
|
|
|
call assert_fails('Xprev', 'E553')
|
|
|
|
|
call assert_fails('Xpfile', 'E553')
|
|
|
|
|
Xnfile
|
2022-07-16 18:10:25 -07:00
|
|
|
|
call assert_equal('Xqftestfile2', @%)
|
2016-12-12 13:06:02 -07:00
|
|
|
|
call assert_equal(10, line('.'))
|
|
|
|
|
Xpfile
|
2022-07-16 18:10:25 -07:00
|
|
|
|
call assert_equal('Xqftestfile1', @%)
|
2016-12-12 13:06:02 -07:00
|
|
|
|
call assert_equal(6, line('.'))
|
2019-06-05 19:52:38 -07:00
|
|
|
|
5Xcc
|
|
|
|
|
call assert_equal(5, g:Xgetlist({'idx':0}).idx)
|
|
|
|
|
2Xcc
|
|
|
|
|
call assert_equal(2, g:Xgetlist({'idx':0}).idx)
|
2021-05-20 15:05:39 -07:00
|
|
|
|
if a:cchar == 'c'
|
|
|
|
|
cc
|
|
|
|
|
else
|
|
|
|
|
ll
|
|
|
|
|
endif
|
|
|
|
|
call assert_equal(2, g:Xgetlist({'idx':0}).idx)
|
2019-06-05 19:52:38 -07:00
|
|
|
|
10Xcc
|
|
|
|
|
call assert_equal(6, g:Xgetlist({'idx':0}).idx)
|
2016-12-12 13:06:02 -07:00
|
|
|
|
Xlast
|
2017-12-18 19:37:11 -07:00
|
|
|
|
Xprev
|
2022-07-16 18:10:25 -07:00
|
|
|
|
call assert_equal('Xqftestfile2', @%)
|
2016-12-12 13:06:02 -07:00
|
|
|
|
call assert_equal(11, line('.'))
|
|
|
|
|
call assert_fails('Xnext', 'E553')
|
|
|
|
|
call assert_fails('Xnfile', 'E553')
|
2021-05-20 15:05:39 -07:00
|
|
|
|
" To process the range using quickfix list entries, directly use the
|
|
|
|
|
" quickfix commands (don't use the user defined commands)
|
|
|
|
|
if a:cchar == 'c'
|
|
|
|
|
$cc
|
|
|
|
|
else
|
|
|
|
|
$ll
|
|
|
|
|
endif
|
|
|
|
|
call assert_equal(6, g:Xgetlist({'idx':0}).idx)
|
2016-12-12 13:06:02 -07:00
|
|
|
|
Xrewind
|
2022-07-16 18:10:25 -07:00
|
|
|
|
call assert_equal('Xqftestfile1', @%)
|
2016-12-12 13:06:02 -07:00
|
|
|
|
call assert_equal(5, line('.'))
|
|
|
|
|
|
2017-12-18 19:37:11 -07:00
|
|
|
|
10Xnext
|
2022-07-16 18:10:25 -07:00
|
|
|
|
call assert_equal('Xqftestfile2', @%)
|
2017-12-18 19:37:11 -07:00
|
|
|
|
call assert_equal(11, line('.'))
|
|
|
|
|
10Xprev
|
2022-07-16 18:10:25 -07:00
|
|
|
|
call assert_equal('Xqftestfile1', @%)
|
2017-12-18 19:37:11 -07:00
|
|
|
|
call assert_equal(5, line('.'))
|
|
|
|
|
|
2019-06-05 19:52:38 -07:00
|
|
|
|
" Jumping to an error from the error window using cc command
|
2022-10-12 23:31:10 -07:00
|
|
|
|
let lines =<< trim END
|
|
|
|
|
Xqftestfile1:5:Line5
|
|
|
|
|
Xqftestfile1:6:Line6
|
|
|
|
|
Xqftestfile2:10:Line10
|
|
|
|
|
Xqftestfile2:11:Line11
|
|
|
|
|
END
|
|
|
|
|
Xgetexpr lines
|
2019-06-05 19:52:38 -07:00
|
|
|
|
Xopen
|
|
|
|
|
10Xcc
|
|
|
|
|
call assert_equal(11, line('.'))
|
2022-07-16 18:10:25 -07:00
|
|
|
|
call assert_equal('Xqftestfile2', @%)
|
2022-07-01 18:52:05 -07:00
|
|
|
|
Xopen
|
|
|
|
|
call cursor(2, 1)
|
|
|
|
|
if a:cchar == 'c'
|
|
|
|
|
.cc
|
|
|
|
|
else
|
|
|
|
|
.ll
|
|
|
|
|
endif
|
|
|
|
|
call assert_equal(6, line('.'))
|
2022-07-16 18:10:25 -07:00
|
|
|
|
call assert_equal('Xqftestfile1', @%)
|
2019-06-05 19:52:38 -07:00
|
|
|
|
|
|
|
|
|
" Jumping to an error from the error window (when only the error window is
|
|
|
|
|
" present)
|
|
|
|
|
Xopen | only
|
|
|
|
|
Xlast 1
|
|
|
|
|
call assert_equal(5, line('.'))
|
2022-07-16 18:10:25 -07:00
|
|
|
|
call assert_equal('Xqftestfile1', @%)
|
2019-06-05 19:52:38 -07:00
|
|
|
|
|
2017-12-17 18:56:01 -07:00
|
|
|
|
Xexpr ""
|
|
|
|
|
call assert_fails('Xnext', 'E42:')
|
|
|
|
|
|
2016-12-12 13:06:02 -07:00
|
|
|
|
call delete('Xqftestfile1')
|
|
|
|
|
call delete('Xqftestfile2')
|
2019-04-14 15:18:21 -07:00
|
|
|
|
|
|
|
|
|
" Should be able to use next/prev with invalid entries
|
|
|
|
|
Xexpr ""
|
|
|
|
|
call assert_equal(0, g:Xgetlist({'idx' : 0}).idx)
|
|
|
|
|
call assert_equal(0, g:Xgetlist({'size' : 0}).size)
|
2020-10-05 21:07:40 -07:00
|
|
|
|
Xaddexpr ['foo', 'bar', 'baz', 'quux', 'sh|moo']
|
2019-04-14 15:18:21 -07:00
|
|
|
|
call assert_equal(5, g:Xgetlist({'size' : 0}).size)
|
|
|
|
|
Xlast
|
|
|
|
|
call assert_equal(5, g:Xgetlist({'idx' : 0}).idx)
|
|
|
|
|
Xfirst
|
|
|
|
|
call assert_equal(1, g:Xgetlist({'idx' : 0}).idx)
|
|
|
|
|
2Xnext
|
|
|
|
|
call assert_equal(3, g:Xgetlist({'idx' : 0}).idx)
|
2017-07-16 08:32:32 -07:00
|
|
|
|
endfunc
|
2016-12-12 13:06:02 -07:00
|
|
|
|
|
2017-07-16 08:32:32 -07:00
|
|
|
|
func Test_browse()
|
2016-12-12 13:06:02 -07:00
|
|
|
|
call Xtest_browse('c')
|
|
|
|
|
call Xtest_browse('l')
|
2017-07-16 08:32:32 -07:00
|
|
|
|
endfunc
|
2016-12-12 13:06:02 -07:00
|
|
|
|
|
2017-07-16 08:32:32 -07:00
|
|
|
|
func s:test_xhelpgrep(cchar)
|
2016-12-12 13:05:47 -07:00
|
|
|
|
call s:setup_commands(a:cchar)
|
|
|
|
|
Xhelpgrep quickfix
|
|
|
|
|
Xopen
|
|
|
|
|
if a:cchar == 'c'
|
|
|
|
|
let title_text = ':helpgrep quickfix'
|
|
|
|
|
else
|
|
|
|
|
let title_text = ':lhelpgrep quickfix'
|
|
|
|
|
endif
|
|
|
|
|
call assert_true(w:quickfix_title =~ title_text, w:quickfix_title)
|
2017-12-18 19:37:11 -07:00
|
|
|
|
|
|
|
|
|
" Jumping to a help topic should open the help window
|
|
|
|
|
only
|
|
|
|
|
Xnext
|
|
|
|
|
call assert_true(&buftype == 'help')
|
|
|
|
|
call assert_true(winnr('$') == 2)
|
|
|
|
|
" Jumping to the next match should reuse the help window
|
|
|
|
|
Xnext
|
|
|
|
|
call assert_true(&buftype == 'help')
|
|
|
|
|
call assert_true(winnr() == 1)
|
|
|
|
|
call assert_true(winnr('$') == 2)
|
|
|
|
|
" Jumping to the next match from the quickfix window should reuse the help
|
|
|
|
|
" window
|
|
|
|
|
Xopen
|
|
|
|
|
Xnext
|
|
|
|
|
call assert_true(&buftype == 'help')
|
|
|
|
|
call assert_true(winnr() == 1)
|
|
|
|
|
call assert_true(winnr('$') == 2)
|
2021-07-31 10:10:44 -07:00
|
|
|
|
call assert_match('|\d\+ col \d\+-\d\+|', getbufline(winbufnr(2), 1)[0])
|
2017-12-18 19:37:11 -07:00
|
|
|
|
|
2016-12-13 12:15:10 -07:00
|
|
|
|
" This wipes out the buffer, make sure that doesn't cause trouble.
|
2016-12-12 13:05:47 -07:00
|
|
|
|
Xclose
|
2017-12-17 18:56:01 -07:00
|
|
|
|
|
2020-07-25 05:17:01 -07:00
|
|
|
|
" When the current window is vertically split, jumping to a help match
|
|
|
|
|
" should open the help window at the top.
|
|
|
|
|
only | enew
|
|
|
|
|
let w1 = win_getid()
|
|
|
|
|
vert new
|
|
|
|
|
let w2 = win_getid()
|
|
|
|
|
Xnext
|
|
|
|
|
let w3 = win_getid()
|
|
|
|
|
call assert_true(&buftype == 'help')
|
|
|
|
|
call assert_true(winnr() == 1)
|
|
|
|
|
" See jump_to_help_window() for details
|
|
|
|
|
let w2_width = winwidth(w2)
|
|
|
|
|
if w2_width != &columns && w2_width < 80
|
|
|
|
|
call assert_equal(['col', [['leaf', w3],
|
|
|
|
|
\ ['row', [['leaf', w2], ['leaf', w1]]]]], winlayout())
|
|
|
|
|
else
|
|
|
|
|
call assert_equal(['row', [['col', [['leaf', w3], ['leaf', w2]]],
|
|
|
|
|
\ ['leaf', w1]]] , winlayout())
|
|
|
|
|
endif
|
|
|
|
|
|
|
|
|
|
new | only
|
|
|
|
|
set buftype=help
|
|
|
|
|
set modified
|
|
|
|
|
call assert_fails('Xnext', 'E37:')
|
|
|
|
|
set nomodified
|
|
|
|
|
new | only
|
|
|
|
|
|
2019-04-14 13:54:33 -07:00
|
|
|
|
if a:cchar == 'l'
|
|
|
|
|
" When a help window is present, running :lhelpgrep should reuse the
|
|
|
|
|
" help window and not the current window
|
|
|
|
|
new | only
|
|
|
|
|
call g:Xsetlist([], 'f')
|
|
|
|
|
help index.txt
|
|
|
|
|
wincmd w
|
|
|
|
|
lhelpgrep quickfix
|
|
|
|
|
call assert_equal(1, winnr())
|
|
|
|
|
call assert_notequal([], getloclist(1))
|
|
|
|
|
call assert_equal([], getloclist(2))
|
|
|
|
|
endif
|
|
|
|
|
|
2017-12-18 19:37:11 -07:00
|
|
|
|
new | only
|
|
|
|
|
|
2017-12-17 18:56:01 -07:00
|
|
|
|
" Search for non existing help string
|
|
|
|
|
call assert_fails('Xhelpgrep a1b2c3', 'E480:')
|
2019-09-18 08:49:11 -07:00
|
|
|
|
" Invalid regular expression
|
2022-11-04 16:24:06 -07:00
|
|
|
|
call assert_fails('Xhelpgrep \@<!', 'E866:')
|
2017-07-16 08:32:32 -07:00
|
|
|
|
endfunc
|
2016-12-12 13:05:47 -07:00
|
|
|
|
|
2017-07-16 08:32:32 -07:00
|
|
|
|
func Test_helpgrep()
|
2016-12-12 13:05:47 -07:00
|
|
|
|
call s:test_xhelpgrep('c')
|
2017-03-11 04:06:10 -07:00
|
|
|
|
helpclose
|
2016-12-12 13:05:47 -07:00
|
|
|
|
call s:test_xhelpgrep('l')
|
2016-12-13 12:15:10 -07:00
|
|
|
|
endfunc
|
|
|
|
|
|
2022-10-12 19:13:17 -07:00
|
|
|
|
" When running the :helpgrep command, if an autocmd modifies the 'cpoptions'
|
|
|
|
|
" value, then Vim crashes. (issue fixed by 7.2b-004 and 8.2.4453)
|
2022-10-12 18:43:06 -07:00
|
|
|
|
func Test_helpgrep_restore_cpo_aucmd()
|
|
|
|
|
let save_cpo = &cpo
|
|
|
|
|
augroup QF_Test
|
|
|
|
|
au!
|
|
|
|
|
autocmd BufNew * set cpo=acd
|
|
|
|
|
augroup END
|
|
|
|
|
|
|
|
|
|
helpgrep quickfix
|
|
|
|
|
call assert_equal('acd', &cpo)
|
|
|
|
|
%bw!
|
|
|
|
|
|
|
|
|
|
set cpo&vim
|
|
|
|
|
augroup QF_Test
|
|
|
|
|
au!
|
|
|
|
|
autocmd BufReadPost * set cpo=
|
|
|
|
|
augroup END
|
|
|
|
|
|
|
|
|
|
helpgrep buffer
|
|
|
|
|
call assert_equal('', &cpo)
|
|
|
|
|
|
|
|
|
|
augroup QF_Test
|
|
|
|
|
au!
|
|
|
|
|
augroup END
|
|
|
|
|
%bw!
|
|
|
|
|
let &cpo = save_cpo
|
|
|
|
|
endfunc
|
|
|
|
|
|
2016-12-13 12:15:10 -07:00
|
|
|
|
func Test_errortitle()
|
|
|
|
|
augroup QfBufWinEnter
|
|
|
|
|
au!
|
|
|
|
|
au BufWinEnter * :let g:a=get(w:, 'quickfix_title', 'NONE')
|
|
|
|
|
augroup END
|
|
|
|
|
copen
|
|
|
|
|
let a=[{'lnum': 308, 'bufnr': bufnr(''), 'col': 58, 'valid': 1, 'vcol': 0, 'nr': 0, 'type': '', 'pattern': '', 'text': ' au BufWinEnter * :let g:a=get(w:, ''quickfix_title'', ''NONE'')'}]
|
|
|
|
|
call setqflist(a)
|
|
|
|
|
call assert_equal(':setqflist()', g:a)
|
|
|
|
|
augroup QfBufWinEnter
|
|
|
|
|
au!
|
|
|
|
|
augroup END
|
|
|
|
|
augroup! QfBufWinEnter
|
|
|
|
|
endfunc
|
|
|
|
|
|
|
|
|
|
func Test_vimgreptitle()
|
|
|
|
|
augroup QfBufWinEnter
|
|
|
|
|
au!
|
|
|
|
|
au BufWinEnter * :let g:a=get(w:, 'quickfix_title', 'NONE')
|
|
|
|
|
augroup END
|
|
|
|
|
try
|
|
|
|
|
vimgrep /pattern/j file
|
|
|
|
|
catch /E480/
|
|
|
|
|
endtry
|
|
|
|
|
copen
|
|
|
|
|
call assert_equal(': vimgrep /pattern/j file', g:a)
|
|
|
|
|
augroup QfBufWinEnter
|
|
|
|
|
au!
|
|
|
|
|
augroup END
|
|
|
|
|
augroup! QfBufWinEnter
|
|
|
|
|
endfunc
|
|
|
|
|
|
2021-10-23 18:55:04 -07:00
|
|
|
|
func Test_bufwinenter_once()
|
|
|
|
|
augroup QfBufWinEnter
|
|
|
|
|
au!
|
|
|
|
|
au BufWinEnter * let g:got_afile ..= 'got ' .. expand('<afile>')
|
|
|
|
|
augroup END
|
|
|
|
|
let g:got_afile = ''
|
|
|
|
|
copen
|
|
|
|
|
call assert_equal('got quickfix', g:got_afile)
|
|
|
|
|
|
|
|
|
|
cclose
|
|
|
|
|
unlet g:got_afile
|
|
|
|
|
augroup QfBufWinEnter
|
|
|
|
|
au!
|
|
|
|
|
augroup END
|
|
|
|
|
augroup! QfBufWinEnter
|
|
|
|
|
endfunc
|
|
|
|
|
|
2017-07-16 08:32:32 -07:00
|
|
|
|
func XqfTitleTests(cchar)
|
2016-12-12 13:05:34 -07:00
|
|
|
|
call s:setup_commands(a:cchar)
|
2016-12-13 12:15:10 -07:00
|
|
|
|
|
2016-12-12 13:05:34 -07:00
|
|
|
|
Xgetexpr ['file:1:1:message']
|
|
|
|
|
let l = g:Xgetlist()
|
2016-12-13 12:15:10 -07:00
|
|
|
|
if a:cchar == 'c'
|
|
|
|
|
call setqflist(l, 'r')
|
|
|
|
|
else
|
|
|
|
|
call setloclist(0, l, 'r')
|
|
|
|
|
endif
|
|
|
|
|
|
2016-12-12 13:05:34 -07:00
|
|
|
|
Xopen
|
2016-12-13 12:15:10 -07:00
|
|
|
|
if a:cchar == 'c'
|
|
|
|
|
let title = ':setqflist()'
|
|
|
|
|
else
|
|
|
|
|
let title = ':setloclist()'
|
|
|
|
|
endif
|
|
|
|
|
call assert_equal(title, w:quickfix_title)
|
2016-12-12 13:05:34 -07:00
|
|
|
|
Xclose
|
2017-07-16 08:32:32 -07:00
|
|
|
|
endfunc
|
2016-12-13 12:15:10 -07:00
|
|
|
|
|
|
|
|
|
" Tests for quickfix window's title
|
2017-07-16 08:32:32 -07:00
|
|
|
|
func Test_qf_title()
|
2016-12-12 13:05:34 -07:00
|
|
|
|
call XqfTitleTests('c')
|
|
|
|
|
call XqfTitleTests('l')
|
2017-07-16 08:32:32 -07:00
|
|
|
|
endfunc
|
2016-12-13 12:15:10 -07:00
|
|
|
|
|
|
|
|
|
" Tests for 'errorformat'
|
2017-07-16 08:32:32 -07:00
|
|
|
|
func Test_efm()
|
2016-12-13 12:15:10 -07:00
|
|
|
|
let save_efm = &efm
|
|
|
|
|
set efm=%EEEE%m,%WWWW%m,%+CCCC%.%#,%-GGGG%.%#
|
|
|
|
|
cgetexpr ['WWWW', 'EEEE', 'CCCC']
|
|
|
|
|
let l = strtrans(string(map(getqflist(), '[v:val.text, v:val.valid]')))
|
|
|
|
|
call assert_equal("[['W', 1], ['E^@CCCC', 1]]", l)
|
|
|
|
|
cgetexpr ['WWWW', 'GGGG', 'EEEE', 'CCCC']
|
|
|
|
|
let l = strtrans(string(map(getqflist(), '[v:val.text, v:val.valid]')))
|
|
|
|
|
call assert_equal("[['W', 1], ['E^@CCCC', 1]]", l)
|
|
|
|
|
cgetexpr ['WWWW', 'GGGG', 'ZZZZ', 'EEEE', 'CCCC', 'YYYY']
|
|
|
|
|
let l = strtrans(string(map(getqflist(), '[v:val.text, v:val.valid]')))
|
|
|
|
|
call assert_equal("[['W', 1], ['ZZZZ', 0], ['E^@CCCC', 1], ['YYYY', 0]]", l)
|
|
|
|
|
let &efm = save_efm
|
2017-07-16 08:32:32 -07:00
|
|
|
|
endfunc
|
2016-12-13 12:15:10 -07:00
|
|
|
|
|
|
|
|
|
" This will test for problems in quickfix:
|
|
|
|
|
" A. incorrectly copying location lists which caused the location list to show
|
|
|
|
|
" a different name than the file that was actually being displayed.
|
|
|
|
|
" B. not reusing the window for which the location list window is opened but
|
|
|
|
|
" instead creating new windows.
|
|
|
|
|
" C. make sure that the location list window is not reused instead of the
|
|
|
|
|
" window it belongs to.
|
|
|
|
|
"
|
|
|
|
|
" Set up the test environment:
|
2017-07-16 08:32:32 -07:00
|
|
|
|
func ReadTestProtocol(name)
|
2016-12-13 12:15:10 -07:00
|
|
|
|
let base = substitute(a:name, '\v^test://(.*)%(\.[^.]+)?', '\1', '')
|
|
|
|
|
let word = substitute(base, '\v(.*)\..*', '\1', '')
|
|
|
|
|
|
|
|
|
|
setl modifiable
|
|
|
|
|
setl noreadonly
|
|
|
|
|
setl noswapfile
|
|
|
|
|
setl bufhidden=delete
|
|
|
|
|
%del _
|
|
|
|
|
" For problem 2:
|
|
|
|
|
" 'buftype' has to be set to reproduce the constant opening of new windows
|
|
|
|
|
setl buftype=nofile
|
|
|
|
|
|
|
|
|
|
call setline(1, word)
|
|
|
|
|
|
|
|
|
|
setl nomodified
|
|
|
|
|
setl nomodifiable
|
|
|
|
|
setl readonly
|
|
|
|
|
exe 'doautocmd BufRead ' . substitute(a:name, '\v^test://(.*)', '\1', '')
|
2017-07-16 08:32:32 -07:00
|
|
|
|
endfunc
|
2016-12-13 12:15:10 -07:00
|
|
|
|
|
2017-07-16 08:32:32 -07:00
|
|
|
|
func Test_locationlist()
|
2022-03-23 21:29:26 -07:00
|
|
|
|
enew
|
2016-12-13 12:15:10 -07:00
|
|
|
|
|
2022-03-23 21:29:26 -07:00
|
|
|
|
augroup testgroup
|
|
|
|
|
au!
|
|
|
|
|
autocmd BufReadCmd test://* call ReadTestProtocol(expand("<amatch>"))
|
|
|
|
|
augroup END
|
2016-12-13 12:15:10 -07:00
|
|
|
|
|
2022-03-23 21:29:26 -07:00
|
|
|
|
let words = [ "foo", "bar", "baz", "quux", "shmoo", "spam", "eggs" ]
|
2016-12-13 12:15:10 -07:00
|
|
|
|
|
2022-03-23 21:29:26 -07:00
|
|
|
|
let qflist = []
|
|
|
|
|
for word in words
|
|
|
|
|
call add(qflist, {'filename': 'test://' . word . '.txt', 'text': 'file ' . word . '.txt', })
|
|
|
|
|
" NOTE: problem 1:
|
|
|
|
|
" intentionally not setting 'lnum' so that the quickfix entries are not
|
|
|
|
|
" valid
|
|
|
|
|
eval qflist->setloclist(0, ' ')
|
|
|
|
|
endfor
|
2016-12-13 12:15:10 -07:00
|
|
|
|
|
2022-03-23 21:29:26 -07:00
|
|
|
|
" Test A
|
|
|
|
|
lrewind
|
|
|
|
|
enew
|
|
|
|
|
lopen
|
|
|
|
|
4lnext
|
|
|
|
|
vert split
|
|
|
|
|
wincmd L
|
|
|
|
|
lopen
|
|
|
|
|
wincmd p
|
|
|
|
|
lnext
|
|
|
|
|
let fileName = expand("%")
|
|
|
|
|
wincmd p
|
|
|
|
|
let locationListFileName = substitute(getline(line('.')), '\([^|]*\)|.*', '\1', '')
|
|
|
|
|
let fileName = substitute(fileName, '\\', '/', 'g')
|
|
|
|
|
let locationListFileName = substitute(locationListFileName, '\\', '/', 'g')
|
|
|
|
|
call assert_equal("test://bar.txt", fileName)
|
|
|
|
|
call assert_equal("test://bar.txt", locationListFileName)
|
2016-12-13 12:15:10 -07:00
|
|
|
|
|
2022-03-23 21:29:26 -07:00
|
|
|
|
wincmd n | only
|
2016-12-13 12:15:10 -07:00
|
|
|
|
|
2022-03-23 21:29:26 -07:00
|
|
|
|
" Test B:
|
|
|
|
|
lrewind
|
|
|
|
|
lopen
|
|
|
|
|
2
|
|
|
|
|
exe "normal \<CR>"
|
|
|
|
|
wincmd p
|
|
|
|
|
3
|
|
|
|
|
exe "normal \<CR>"
|
|
|
|
|
wincmd p
|
|
|
|
|
4
|
|
|
|
|
exe "normal \<CR>"
|
|
|
|
|
call assert_equal(2, winnr('$'))
|
|
|
|
|
wincmd n | only
|
2016-12-13 12:15:10 -07:00
|
|
|
|
|
2022-03-23 21:29:26 -07:00
|
|
|
|
" Test C:
|
|
|
|
|
lrewind
|
|
|
|
|
lopen
|
|
|
|
|
" Let's move the location list window to the top to check whether it (the
|
|
|
|
|
" first window found) will be reused when we try to open new windows:
|
|
|
|
|
wincmd K
|
|
|
|
|
2
|
|
|
|
|
exe "normal \<CR>"
|
|
|
|
|
wincmd p
|
|
|
|
|
3
|
|
|
|
|
exe "normal \<CR>"
|
|
|
|
|
wincmd p
|
|
|
|
|
4
|
|
|
|
|
exe "normal \<CR>"
|
|
|
|
|
1wincmd w
|
|
|
|
|
call assert_equal('quickfix', &buftype)
|
|
|
|
|
2wincmd w
|
|
|
|
|
let bufferName = expand("%")
|
|
|
|
|
let bufferName = substitute(bufferName, '\\', '/', 'g')
|
|
|
|
|
call assert_equal('test://quux.txt', bufferName)
|
2016-12-13 12:15:10 -07:00
|
|
|
|
|
2022-03-23 21:29:26 -07:00
|
|
|
|
wincmd n | only
|
2016-12-13 12:15:10 -07:00
|
|
|
|
|
2022-03-23 21:29:26 -07:00
|
|
|
|
augroup! testgroup
|
2017-12-17 18:56:01 -07:00
|
|
|
|
endfunc
|
2016-12-13 12:15:10 -07:00
|
|
|
|
|
2017-07-16 08:32:32 -07:00
|
|
|
|
func Test_locationlist_curwin_was_closed()
|
2022-03-23 21:29:26 -07:00
|
|
|
|
augroup testgroup
|
|
|
|
|
au!
|
|
|
|
|
autocmd BufReadCmd test_curwin.txt call R(expand("<amatch>"))
|
|
|
|
|
augroup END
|
2016-12-13 12:15:10 -07:00
|
|
|
|
|
2022-03-23 21:29:26 -07:00
|
|
|
|
func! R(n)
|
|
|
|
|
quit
|
|
|
|
|
endfunc
|
2016-12-13 12:15:10 -07:00
|
|
|
|
|
2022-03-23 21:29:26 -07:00
|
|
|
|
new
|
|
|
|
|
let q = []
|
|
|
|
|
call add(q, {'filename': 'test_curwin.txt' })
|
|
|
|
|
call setloclist(0, q)
|
|
|
|
|
call assert_fails('lrewind', 'E924:')
|
2016-12-13 12:15:10 -07:00
|
|
|
|
|
2022-03-23 21:29:26 -07:00
|
|
|
|
augroup! testgroup
|
|
|
|
|
delfunc R
|
2017-12-17 18:56:01 -07:00
|
|
|
|
endfunc
|
2016-12-13 12:15:10 -07:00
|
|
|
|
|
2017-07-16 08:32:32 -07:00
|
|
|
|
func Test_locationlist_cross_tab_jump()
|
2017-03-21 11:14:18 -07:00
|
|
|
|
call writefile(['loclistfoo'], 'loclistfoo')
|
|
|
|
|
call writefile(['loclistbar'], 'loclistbar')
|
|
|
|
|
set switchbuf=usetab
|
|
|
|
|
|
|
|
|
|
edit loclistfoo
|
|
|
|
|
tabedit loclistbar
|
|
|
|
|
silent lgrep loclistfoo loclist*
|
|
|
|
|
call assert_equal(1, tabpagenr())
|
|
|
|
|
|
|
|
|
|
enew | only | tabonly
|
|
|
|
|
set switchbuf&vim
|
|
|
|
|
call delete('loclistfoo')
|
|
|
|
|
call delete('loclistbar')
|
2017-07-16 08:32:32 -07:00
|
|
|
|
endfunc
|
2017-03-21 11:14:18 -07:00
|
|
|
|
|
2016-12-13 12:15:10 -07:00
|
|
|
|
" More tests for 'errorformat'
|
2017-07-16 08:32:32 -07:00
|
|
|
|
func Test_efm1()
|
2016-12-13 12:15:10 -07:00
|
|
|
|
if !has('unix')
|
|
|
|
|
" The 'errorformat' setting is different on non-Unix systems.
|
|
|
|
|
" This test works only on Unix-like systems.
|
|
|
|
|
return
|
|
|
|
|
endif
|
|
|
|
|
|
2019-09-23 13:12:02 -07:00
|
|
|
|
let l =<< trim [DATA]
|
2019-10-12 00:48:48 -07:00
|
|
|
|
"Xtestfile", line 4.12: 1506-045 (S) Undeclared identifier fd_set.
|
|
|
|
|
"Xtestfile", line 6 col 19; this is an error
|
|
|
|
|
gcc -c -DHAVE_CONFIsing-prototypes -I/usr/X11R6/include version.c
|
|
|
|
|
Xtestfile:9: parse error before `asd'
|
|
|
|
|
make: *** [vim] Error 1
|
|
|
|
|
in file "Xtestfile" linenr 10: there is an error
|
2021-06-26 07:44:05 -07:00
|
|
|
|
|
2019-10-12 00:48:48 -07:00
|
|
|
|
2 returned
|
|
|
|
|
"Xtestfile", line 11 col 1; this is an error
|
|
|
|
|
"Xtestfile", line 12 col 2; this is another error
|
|
|
|
|
"Xtestfile", line 14:10; this is an error in column 10
|
|
|
|
|
=Xtestfile=, line 15:10; this is another error, but in vcol 10 this time
|
|
|
|
|
"Xtestfile", linenr 16: yet another problem
|
|
|
|
|
Error in "Xtestfile" at line 17:
|
|
|
|
|
x should be a dot
|
|
|
|
|
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx line 17
|
|
|
|
|
^
|
|
|
|
|
Error in "Xtestfile" at line 18:
|
|
|
|
|
x should be a dot
|
|
|
|
|
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx line 18
|
|
|
|
|
.............^
|
|
|
|
|
Error in "Xtestfile" at line 19:
|
|
|
|
|
x should be a dot
|
|
|
|
|
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx line 19
|
|
|
|
|
--------------^
|
|
|
|
|
Error in "Xtestfile" at line 20:
|
|
|
|
|
x should be a dot
|
|
|
|
|
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx line 20
|
|
|
|
|
^
|
2021-06-26 07:44:05 -07:00
|
|
|
|
|
2019-10-12 00:48:48 -07:00
|
|
|
|
Does anyone know what is the problem and how to correction it?
|
|
|
|
|
"Xtestfile", line 21 col 9: What is the title of the quickfix window?
|
|
|
|
|
"Xtestfile", line 22 col 9: What is the title of the quickfix window?
|
2019-09-23 13:12:02 -07:00
|
|
|
|
[DATA]
|
2016-12-13 12:15:10 -07:00
|
|
|
|
|
|
|
|
|
call writefile(l, 'Xerrorfile1')
|
|
|
|
|
call writefile(l[:-2], 'Xerrorfile2')
|
|
|
|
|
|
2019-10-12 00:48:48 -07:00
|
|
|
|
let m =<< [DATA]
|
|
|
|
|
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx line 2
|
|
|
|
|
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx line 3
|
|
|
|
|
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx line 4
|
|
|
|
|
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx line 5
|
|
|
|
|
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx line 6
|
|
|
|
|
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx line 7
|
|
|
|
|
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx line 8
|
|
|
|
|
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx line 9
|
|
|
|
|
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx line 10
|
|
|
|
|
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx line 11
|
|
|
|
|
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx line 12
|
|
|
|
|
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx line 13
|
|
|
|
|
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx line 14
|
|
|
|
|
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx line 15
|
|
|
|
|
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx line 16
|
|
|
|
|
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx line 17
|
|
|
|
|
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx line 18
|
|
|
|
|
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx line 19
|
|
|
|
|
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx line 20
|
|
|
|
|
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx line 21
|
|
|
|
|
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx line 22
|
|
|
|
|
[DATA]
|
2016-12-13 12:15:10 -07:00
|
|
|
|
call writefile(m, 'Xtestfile')
|
|
|
|
|
|
|
|
|
|
let save_efm = &efm
|
|
|
|
|
set efm+==%f=\\,\ line\ %l%*\\D%v%*[^\ ]\ %m
|
|
|
|
|
set efm^=%AError\ in\ \"%f\"\ at\ line\ %l:,%Z%p^,%C%m
|
|
|
|
|
|
|
|
|
|
exe 'cf Xerrorfile2'
|
|
|
|
|
clast
|
|
|
|
|
copen
|
|
|
|
|
call assert_equal(':cf Xerrorfile2', w:quickfix_title)
|
|
|
|
|
wincmd p
|
|
|
|
|
|
|
|
|
|
exe 'cf Xerrorfile1'
|
|
|
|
|
call assert_equal([4, 12], [line('.'), col('.')])
|
|
|
|
|
cn
|
|
|
|
|
call assert_equal([6, 19], [line('.'), col('.')])
|
|
|
|
|
cn
|
|
|
|
|
call assert_equal([9, 2], [line('.'), col('.')])
|
|
|
|
|
cn
|
|
|
|
|
call assert_equal([10, 2], [line('.'), col('.')])
|
|
|
|
|
cn
|
|
|
|
|
call assert_equal([11, 1], [line('.'), col('.')])
|
|
|
|
|
cn
|
|
|
|
|
call assert_equal([12, 2], [line('.'), col('.')])
|
|
|
|
|
cn
|
|
|
|
|
call assert_equal([14, 10], [line('.'), col('.')])
|
|
|
|
|
cn
|
|
|
|
|
call assert_equal([15, 3, 10], [line('.'), col('.'), virtcol('.')])
|
|
|
|
|
cn
|
|
|
|
|
call assert_equal([16, 2], [line('.'), col('.')])
|
|
|
|
|
cn
|
|
|
|
|
call assert_equal([17, 6], [line('.'), col('.')])
|
|
|
|
|
cn
|
|
|
|
|
call assert_equal([18, 7], [line('.'), col('.')])
|
|
|
|
|
cn
|
|
|
|
|
call assert_equal([19, 8], [line('.'), col('.')])
|
|
|
|
|
cn
|
|
|
|
|
call assert_equal([20, 9], [line('.'), col('.')])
|
|
|
|
|
clast
|
|
|
|
|
cprev
|
|
|
|
|
cprev
|
|
|
|
|
wincmd w
|
|
|
|
|
call assert_equal(':cf Xerrorfile1', w:quickfix_title)
|
|
|
|
|
wincmd p
|
|
|
|
|
|
|
|
|
|
let &efm = save_efm
|
|
|
|
|
call delete('Xerrorfile1')
|
|
|
|
|
call delete('Xerrorfile2')
|
|
|
|
|
call delete('Xtestfile')
|
2017-12-17 18:56:01 -07:00
|
|
|
|
endfunc
|
2016-12-13 12:15:10 -07:00
|
|
|
|
|
2016-12-12 13:05:29 -07:00
|
|
|
|
" Test for quickfix directory stack support
|
2017-07-16 08:32:32 -07:00
|
|
|
|
func s:dir_stack_tests(cchar)
|
2016-12-12 13:05:38 -07:00
|
|
|
|
call s:setup_commands(a:cchar)
|
|
|
|
|
|
2016-12-12 13:05:29 -07:00
|
|
|
|
let save_efm=&efm
|
|
|
|
|
set efm=%DEntering\ dir\ '%f',%f:%l:%m,%XLeaving\ dir\ '%f'
|
|
|
|
|
|
2022-10-12 23:31:10 -07:00
|
|
|
|
let lines =<< trim END
|
|
|
|
|
Entering dir 'dir1/a'
|
|
|
|
|
habits2.txt:1:Nine Healthy Habits
|
|
|
|
|
Entering dir 'b'
|
|
|
|
|
habits3.txt:2:0 Hours of television
|
|
|
|
|
habits2.txt:7:5 Small meals
|
|
|
|
|
Entering dir 'dir1/c'
|
|
|
|
|
habits4.txt:3:1 Hour of exercise
|
|
|
|
|
Leaving dir 'dir1/c'
|
|
|
|
|
Leaving dir 'dir1/a'
|
|
|
|
|
habits1.txt:4:2 Liters of water
|
|
|
|
|
Entering dir 'dir2'
|
|
|
|
|
habits5.txt:5:3 Cups of hot green tea
|
|
|
|
|
Leaving dir 'dir2'
|
|
|
|
|
END
|
2016-12-14 08:55:21 -07:00
|
|
|
|
|
|
|
|
|
Xexpr ""
|
|
|
|
|
for l in lines
|
|
|
|
|
Xaddexpr l
|
|
|
|
|
endfor
|
2016-12-12 13:05:29 -07:00
|
|
|
|
|
2016-12-12 13:05:34 -07:00
|
|
|
|
let qf = g:Xgetlist()
|
2016-12-12 13:05:29 -07:00
|
|
|
|
|
2022-06-25 14:31:27 -07:00
|
|
|
|
call assert_equal('dir1/a/habits2.txt', bufname(qf[1].bufnr))
|
2016-12-12 13:05:29 -07:00
|
|
|
|
call assert_equal(1, qf[1].lnum)
|
2022-06-25 14:31:27 -07:00
|
|
|
|
call assert_equal('dir1/a/b/habits3.txt', bufname(qf[3].bufnr))
|
2016-12-12 13:05:29 -07:00
|
|
|
|
call assert_equal(2, qf[3].lnum)
|
2022-06-25 14:31:27 -07:00
|
|
|
|
call assert_equal('dir1/a/habits2.txt', bufname(qf[4].bufnr))
|
2016-12-12 13:05:29 -07:00
|
|
|
|
call assert_equal(7, qf[4].lnum)
|
2022-06-25 14:31:27 -07:00
|
|
|
|
call assert_equal('dir1/c/habits4.txt', bufname(qf[6].bufnr))
|
2016-12-12 13:05:29 -07:00
|
|
|
|
call assert_equal(3, qf[6].lnum)
|
|
|
|
|
call assert_equal('habits1.txt', bufname(qf[9].bufnr))
|
|
|
|
|
call assert_equal(4, qf[9].lnum)
|
2022-06-25 14:31:27 -07:00
|
|
|
|
call assert_equal('dir2/habits5.txt', bufname(qf[11].bufnr))
|
2016-12-12 13:05:29 -07:00
|
|
|
|
call assert_equal(5, qf[11].lnum)
|
|
|
|
|
|
|
|
|
|
let &efm=save_efm
|
2017-07-16 08:32:32 -07:00
|
|
|
|
endfunc
|
2016-12-12 13:05:29 -07:00
|
|
|
|
|
|
|
|
|
" Tests for %D and %X errorformat options
|
2017-07-16 08:32:32 -07:00
|
|
|
|
func Test_efm_dirstack()
|
2016-12-12 13:05:29 -07:00
|
|
|
|
" Create the directory stack and files
|
2021-05-11 15:44:39 -07:00
|
|
|
|
call mkdir('dir1')
|
2021-05-22 22:20:59 -07:00
|
|
|
|
call mkdir('dir1/a')
|
|
|
|
|
call mkdir('dir1/a/b')
|
|
|
|
|
call mkdir('dir1/c')
|
2016-12-12 13:05:29 -07:00
|
|
|
|
call mkdir('dir2')
|
|
|
|
|
|
2022-10-12 23:31:10 -07:00
|
|
|
|
let lines =<< trim END
|
|
|
|
|
Nine Healthy Habits
|
|
|
|
|
0 Hours of television
|
|
|
|
|
1 Hour of exercise
|
|
|
|
|
2 Liters of water
|
|
|
|
|
3 Cups of hot green tea
|
|
|
|
|
4 Short mental breaks
|
|
|
|
|
5 Small meals
|
|
|
|
|
6 AM wake up time
|
|
|
|
|
7 Minutes of laughter
|
|
|
|
|
8 Hours of sleep (at least)
|
|
|
|
|
9 PM end of the day and off to bed
|
|
|
|
|
END
|
2016-12-12 13:05:29 -07:00
|
|
|
|
call writefile(lines, 'habits1.txt')
|
|
|
|
|
call writefile(lines, 'dir1/a/habits2.txt')
|
|
|
|
|
call writefile(lines, 'dir1/a/b/habits3.txt')
|
|
|
|
|
call writefile(lines, 'dir1/c/habits4.txt')
|
|
|
|
|
call writefile(lines, 'dir2/habits5.txt')
|
|
|
|
|
|
|
|
|
|
call s:dir_stack_tests('c')
|
|
|
|
|
call s:dir_stack_tests('l')
|
|
|
|
|
|
|
|
|
|
call delete('dir1', 'rf')
|
|
|
|
|
call delete('dir2', 'rf')
|
|
|
|
|
call delete('habits1.txt')
|
2017-07-16 08:32:32 -07:00
|
|
|
|
endfunc
|
2016-12-12 13:05:29 -07:00
|
|
|
|
|
2017-07-16 07:58:25 -07:00
|
|
|
|
" Test for resync after continuing an ignored message
|
2017-07-16 08:32:32 -07:00
|
|
|
|
func Xefm_ignore_continuations(cchar)
|
2017-07-16 07:58:25 -07:00
|
|
|
|
call s:setup_commands(a:cchar)
|
|
|
|
|
|
|
|
|
|
let save_efm = &efm
|
|
|
|
|
|
|
|
|
|
let &efm =
|
|
|
|
|
\ '%Eerror %m %l,' .
|
|
|
|
|
\ '%-Wignored %m %l,' .
|
|
|
|
|
\ '%+Cmore ignored %m %l,' .
|
|
|
|
|
\ '%Zignored end'
|
2022-10-12 23:31:10 -07:00
|
|
|
|
let lines =<< trim END
|
|
|
|
|
ignored warning 1
|
|
|
|
|
more ignored continuation 2
|
|
|
|
|
ignored end
|
|
|
|
|
error resync 4
|
|
|
|
|
END
|
|
|
|
|
Xgetexpr lines
|
2017-07-16 07:58:25 -07:00
|
|
|
|
let l = map(g:Xgetlist(), '[v:val.text, v:val.valid, v:val.lnum, v:val.type]')
|
|
|
|
|
call assert_equal([['resync', 1, 4, 'E']], l)
|
|
|
|
|
|
|
|
|
|
let &efm = save_efm
|
2017-07-16 08:32:32 -07:00
|
|
|
|
endfunc
|
2017-07-16 07:58:25 -07:00
|
|
|
|
|
2017-07-16 08:32:32 -07:00
|
|
|
|
func Test_efm_ignore_continuations()
|
2017-07-16 07:58:25 -07:00
|
|
|
|
call Xefm_ignore_continuations('c')
|
|
|
|
|
call Xefm_ignore_continuations('l')
|
2017-07-16 08:32:32 -07:00
|
|
|
|
endfunc
|
2017-07-16 07:58:25 -07:00
|
|
|
|
|
2016-12-12 13:06:02 -07:00
|
|
|
|
" Tests for invalid error format specifies
|
2017-07-16 08:32:32 -07:00
|
|
|
|
func Xinvalid_efm_Tests(cchar)
|
2016-12-12 13:06:02 -07:00
|
|
|
|
call s:setup_commands(a:cchar)
|
|
|
|
|
|
|
|
|
|
let save_efm = &efm
|
|
|
|
|
|
|
|
|
|
set efm=%f:%l:%m,%f:%f:%l:%m
|
|
|
|
|
call assert_fails('Xexpr "abc.txt:1:Hello world"', 'E372:')
|
|
|
|
|
|
|
|
|
|
set efm=%f:%l:%m,%f:%l:%r:%m
|
|
|
|
|
call assert_fails('Xexpr "abc.txt:1:Hello world"', 'E373:')
|
|
|
|
|
|
|
|
|
|
set efm=%f:%l:%m,%O:%f:%l:%m
|
|
|
|
|
call assert_fails('Xexpr "abc.txt:1:Hello world"', 'E373:')
|
|
|
|
|
|
|
|
|
|
set efm=%f:%l:%m,%f:%l:%*[^a-z
|
|
|
|
|
call assert_fails('Xexpr "abc.txt:1:Hello world"', 'E374:')
|
|
|
|
|
|
|
|
|
|
set efm=%f:%l:%m,%f:%l:%*c
|
|
|
|
|
call assert_fails('Xexpr "abc.txt:1:Hello world"', 'E375:')
|
|
|
|
|
|
|
|
|
|
set efm=%f:%l:%m,%L%M%N
|
|
|
|
|
call assert_fails('Xexpr "abc.txt:1:Hello world"', 'E376:')
|
|
|
|
|
|
|
|
|
|
set efm=%f:%l:%m,%f:%l:%m:%R
|
|
|
|
|
call assert_fails('Xexpr "abc.txt:1:Hello world"', 'E377:')
|
|
|
|
|
|
2021-05-20 15:49:33 -07:00
|
|
|
|
" Invalid regular expression
|
|
|
|
|
set efm=%\\%%k
|
|
|
|
|
call assert_fails('Xexpr "abc.txt:1:Hello world"', 'E867:')
|
|
|
|
|
|
2016-12-12 13:06:02 -07:00
|
|
|
|
set efm=
|
|
|
|
|
call assert_fails('Xexpr "abc.txt:1:Hello world"', 'E378:')
|
|
|
|
|
|
2022-10-12 19:13:17 -07:00
|
|
|
|
" Empty directory name. When there is an error in parsing new entries, make
|
|
|
|
|
" sure the previous quickfix list is made the current list.
|
|
|
|
|
set efm&
|
|
|
|
|
cexpr ["one", "two"]
|
|
|
|
|
let qf_id = getqflist(#{id: 0}).id
|
2016-12-12 13:06:02 -07:00
|
|
|
|
set efm=%DEntering\ dir\ abc,%f:%l:%m
|
|
|
|
|
call assert_fails('Xexpr ["Entering dir abc", "abc.txt:1:Hello world"]', 'E379:')
|
2022-10-12 19:13:17 -07:00
|
|
|
|
call assert_equal(qf_id, getqflist(#{id: 0}).id)
|
2016-12-12 13:06:02 -07:00
|
|
|
|
|
|
|
|
|
let &efm = save_efm
|
2017-07-16 08:32:32 -07:00
|
|
|
|
endfunc
|
2016-12-12 13:06:02 -07:00
|
|
|
|
|
2017-07-16 08:32:32 -07:00
|
|
|
|
func Test_invalid_efm()
|
2016-12-12 13:06:02 -07:00
|
|
|
|
call Xinvalid_efm_Tests('c')
|
|
|
|
|
call Xinvalid_efm_Tests('l')
|
2017-07-16 08:32:32 -07:00
|
|
|
|
endfunc
|
2016-12-12 13:06:02 -07:00
|
|
|
|
|
2016-12-12 13:05:47 -07:00
|
|
|
|
" TODO:
|
|
|
|
|
" Add tests for the following formats in 'errorformat'
|
2016-12-12 13:06:02 -07:00
|
|
|
|
" %r %O
|
2017-07-16 08:32:32 -07:00
|
|
|
|
func Test_efm2()
|
2016-12-12 13:05:47 -07:00
|
|
|
|
let save_efm = &efm
|
|
|
|
|
|
|
|
|
|
" Test for %s format in efm
|
|
|
|
|
set efm=%f:%s
|
|
|
|
|
cexpr 'Xtestfile:Line search text'
|
|
|
|
|
let l = getqflist()
|
2019-09-18 13:00:06 -07:00
|
|
|
|
call assert_equal('^\VLine search text\$', l[0].pattern)
|
|
|
|
|
call assert_equal(0, l[0].lnum)
|
2016-12-12 13:05:47 -07:00
|
|
|
|
|
2017-12-17 18:56:01 -07:00
|
|
|
|
let l = split(execute('clist', ''), "\n")
|
|
|
|
|
call assert_equal([' 1 Xtestfile:^\VLine search text\$: '], l)
|
|
|
|
|
|
2021-05-20 15:49:33 -07:00
|
|
|
|
" Test for a long line
|
|
|
|
|
cexpr 'Xtestfile:' . repeat('a', 1026)
|
|
|
|
|
let l = getqflist()
|
|
|
|
|
call assert_equal('^\V' . repeat('a', 1019) . '\$', l[0].pattern)
|
|
|
|
|
|
2016-12-12 13:06:02 -07:00
|
|
|
|
" Test for %P, %Q and %t format specifiers
|
2019-09-23 13:12:02 -07:00
|
|
|
|
let lines =<< trim [DATA]
|
2019-10-12 00:48:48 -07:00
|
|
|
|
[Xtestfile1]
|
|
|
|
|
(1,17) error: ';' missing
|
|
|
|
|
(21,2) warning: variable 'z' not defined
|
|
|
|
|
(67,3) error: end of file found before string ended
|
|
|
|
|
--
|
|
|
|
|
|
|
|
|
|
[Xtestfile2]
|
|
|
|
|
--
|
|
|
|
|
|
|
|
|
|
[Xtestfile3]
|
|
|
|
|
NEW compiler v1.1
|
|
|
|
|
(2,2) warning: variable 'x' not defined
|
|
|
|
|
(67,3) warning: 's' already defined
|
|
|
|
|
--
|
2019-09-23 13:12:02 -07:00
|
|
|
|
[DATA]
|
2022-04-11 13:56:15 -07:00
|
|
|
|
|
2017-12-17 18:56:01 -07:00
|
|
|
|
set efm=%+P[%f]%r,(%l\\,%c)%*[\ ]%t%*[^:]:\ %m,%+Q--%r
|
2017-12-17 18:51:51 -07:00
|
|
|
|
" To exercise the push/pop file functionality in quickfix, the test files
|
|
|
|
|
" need to be created.
|
|
|
|
|
call writefile(['Line1'], 'Xtestfile1')
|
|
|
|
|
call writefile(['Line2'], 'Xtestfile2')
|
|
|
|
|
call writefile(['Line3'], 'Xtestfile3')
|
2016-12-14 08:55:21 -07:00
|
|
|
|
cexpr ""
|
|
|
|
|
for l in lines
|
|
|
|
|
caddexpr l
|
|
|
|
|
endfor
|
2016-12-12 13:05:47 -07:00
|
|
|
|
let l = getqflist()
|
2017-12-17 18:56:01 -07:00
|
|
|
|
call assert_equal(12, len(l))
|
2016-12-12 13:05:47 -07:00
|
|
|
|
call assert_equal(21, l[2].lnum)
|
|
|
|
|
call assert_equal(2, l[2].col)
|
2016-12-12 13:06:02 -07:00
|
|
|
|
call assert_equal('w', l[2].type)
|
|
|
|
|
call assert_equal('e', l[3].type)
|
2017-12-17 18:51:51 -07:00
|
|
|
|
call delete('Xtestfile1')
|
|
|
|
|
call delete('Xtestfile2')
|
|
|
|
|
call delete('Xtestfile3')
|
2016-12-12 13:06:02 -07:00
|
|
|
|
|
2021-05-20 15:49:33 -07:00
|
|
|
|
" Test for %P, %Q with non-existing files
|
|
|
|
|
cexpr lines
|
|
|
|
|
let l = getqflist()
|
|
|
|
|
call assert_equal(14, len(l))
|
|
|
|
|
call assert_equal('[Xtestfile1]', l[0].text)
|
|
|
|
|
call assert_equal('[Xtestfile2]', l[6].text)
|
|
|
|
|
call assert_equal('[Xtestfile3]', l[9].text)
|
|
|
|
|
|
2016-12-12 13:06:02 -07:00
|
|
|
|
" Tests for %E, %C and %Z format specifiers
|
2019-09-23 13:12:02 -07:00
|
|
|
|
let lines =<< trim [DATA]
|
2019-10-12 00:48:48 -07:00
|
|
|
|
Error 275
|
|
|
|
|
line 42
|
|
|
|
|
column 3
|
|
|
|
|
' ' expected after '--'
|
2019-09-23 13:12:02 -07:00
|
|
|
|
[DATA]
|
|
|
|
|
|
2016-12-12 13:06:02 -07:00
|
|
|
|
set efm=%EError\ %n,%Cline\ %l,%Ccolumn\ %c,%Z%m
|
|
|
|
|
cgetexpr lines
|
|
|
|
|
let l = getqflist()
|
|
|
|
|
call assert_equal(275, l[0].nr)
|
|
|
|
|
call assert_equal(42, l[0].lnum)
|
|
|
|
|
call assert_equal(3, l[0].col)
|
|
|
|
|
call assert_equal('E', l[0].type)
|
|
|
|
|
call assert_equal("\n' ' expected after '--'", l[0].text)
|
|
|
|
|
|
|
|
|
|
" Test for %>
|
2019-09-23 13:12:02 -07:00
|
|
|
|
let lines =<< trim [DATA]
|
2019-10-12 00:48:48 -07:00
|
|
|
|
Error in line 147 of foo.c:
|
|
|
|
|
unknown variable 'i'
|
2019-09-23 13:12:02 -07:00
|
|
|
|
[DATA]
|
|
|
|
|
|
2016-12-12 13:06:02 -07:00
|
|
|
|
set efm=unknown\ variable\ %m,%E%>Error\ in\ line\ %l\ of\ %f:,%Z%m
|
|
|
|
|
cgetexpr lines
|
|
|
|
|
let l = getqflist()
|
|
|
|
|
call assert_equal(147, l[0].lnum)
|
|
|
|
|
call assert_equal('E', l[0].type)
|
|
|
|
|
call assert_equal("\nunknown variable 'i'", l[0].text)
|
2016-12-12 13:05:47 -07:00
|
|
|
|
|
2017-02-14 21:23:11 -07:00
|
|
|
|
" Test for %A, %C and other formats
|
2019-09-23 13:12:02 -07:00
|
|
|
|
let lines =<< trim [DATA]
|
2022-04-11 13:56:15 -07:00
|
|
|
|
==============================================================
|
|
|
|
|
FAIL: testGetTypeIdCachesResult (dbfacadeTest.DjsDBFacadeTest)
|
|
|
|
|
--------------------------------------------------------------
|
|
|
|
|
Traceback (most recent call last):
|
|
|
|
|
File "unittests/dbfacadeTest.py", line 89, in testFoo
|
|
|
|
|
self.assertEquals(34, dtid)
|
|
|
|
|
File "/usr/lib/python2.2/unittest.py", line 286, in
|
|
|
|
|
failUnlessEqual
|
|
|
|
|
raise self.failureException, \\
|
|
|
|
|
W:AssertionError: 34 != 33
|
|
|
|
|
|
|
|
|
|
--------------------------------------------------------------
|
|
|
|
|
Ran 27 tests in 0.063s
|
2019-09-23 13:12:02 -07:00
|
|
|
|
[DATA]
|
2022-04-11 13:56:15 -07:00
|
|
|
|
|
2021-05-20 15:49:33 -07:00
|
|
|
|
set efm=%C\ %.%#,%A\ \ File\ \"%f\"\\,\ line\ %l%.%#,%Z%[%^\ ]%\\@=%t:%m
|
2017-02-14 21:23:11 -07:00
|
|
|
|
cgetexpr lines
|
|
|
|
|
let l = getqflist()
|
|
|
|
|
call assert_equal(8, len(l))
|
|
|
|
|
call assert_equal(89, l[4].lnum)
|
|
|
|
|
call assert_equal(1, l[4].valid)
|
2022-06-25 14:31:27 -07:00
|
|
|
|
call assert_equal('unittests/dbfacadeTest.py', bufname(l[4].bufnr))
|
2021-05-20 15:49:33 -07:00
|
|
|
|
call assert_equal('W', l[4].type)
|
2017-02-14 21:23:11 -07:00
|
|
|
|
|
2019-03-31 17:34:06 -07:00
|
|
|
|
" Test for %o
|
|
|
|
|
set efm=%f(%o):%l\ %m
|
2019-06-06 02:22:55 -07:00
|
|
|
|
cgetexpr ['Xotestfile(Language.PureScript.Types):20 Error']
|
|
|
|
|
call writefile(['Line1'], 'Xotestfile')
|
2019-03-31 17:34:06 -07:00
|
|
|
|
let l = getqflist()
|
|
|
|
|
call assert_equal(1, len(l), string(l))
|
|
|
|
|
call assert_equal('Language.PureScript.Types', l[0].module)
|
|
|
|
|
copen
|
|
|
|
|
call assert_equal('Language.PureScript.Types|20| Error', getline(1))
|
|
|
|
|
call feedkeys("\<CR>", 'xn')
|
2019-06-06 02:22:55 -07:00
|
|
|
|
call assert_equal('Xotestfile', expand('%:t'))
|
2019-03-31 17:34:06 -07:00
|
|
|
|
cclose
|
|
|
|
|
bd
|
2019-06-06 02:22:55 -07:00
|
|
|
|
call delete("Xotestfile")
|
2019-03-31 17:34:06 -07:00
|
|
|
|
|
2021-05-20 15:49:33 -07:00
|
|
|
|
" Test for a long module name
|
|
|
|
|
cexpr 'Xtest(' . repeat('m', 1026) . '):15 message'
|
|
|
|
|
let l = getqflist()
|
|
|
|
|
" call assert_equal(repeat('m', 1024), l[0].module)
|
|
|
|
|
call assert_equal(repeat('m', 1023), l[0].module)
|
|
|
|
|
call assert_equal(15, l[0].lnum)
|
|
|
|
|
call assert_equal('message', l[0].text)
|
|
|
|
|
|
2017-12-18 19:37:11 -07:00
|
|
|
|
" The following sequence of commands used to crash Vim
|
|
|
|
|
set efm=%W%m
|
|
|
|
|
cgetexpr ['msg1']
|
|
|
|
|
let l = getqflist()
|
|
|
|
|
call assert_equal(1, len(l), string(l))
|
|
|
|
|
call assert_equal('msg1', l[0].text)
|
|
|
|
|
set efm=%C%m
|
|
|
|
|
lexpr 'msg2'
|
|
|
|
|
let l = getloclist(0)
|
|
|
|
|
call assert_equal(1, len(l), string(l))
|
|
|
|
|
call assert_equal('msg2', l[0].text)
|
|
|
|
|
lopen
|
|
|
|
|
call setqflist([], 'r')
|
|
|
|
|
caddbuf
|
|
|
|
|
let l = getqflist()
|
|
|
|
|
call assert_equal(1, len(l), string(l))
|
|
|
|
|
call assert_equal('|| msg2', l[0].text)
|
|
|
|
|
|
2019-09-03 23:03:45 -07:00
|
|
|
|
" When matching error lines, case should be ignored. Test for this.
|
|
|
|
|
set noignorecase
|
|
|
|
|
let l=getqflist({'lines' : ['Xtest:FOO10:Line 20'], 'efm':'%f:foo%l:%m'})
|
|
|
|
|
call assert_equal(10, l.items[0].lnum)
|
|
|
|
|
call assert_equal('Line 20', l.items[0].text)
|
|
|
|
|
set ignorecase&
|
|
|
|
|
|
2017-12-18 19:37:11 -07:00
|
|
|
|
new | only
|
2016-12-12 13:05:47 -07:00
|
|
|
|
let &efm = save_efm
|
2017-07-16 08:32:32 -07:00
|
|
|
|
endfunc
|
2016-12-12 13:05:47 -07:00
|
|
|
|
|
2021-01-01 21:13:10 -07:00
|
|
|
|
" Test for '%t' (error type) field in 'efm'
|
|
|
|
|
func Test_efm_error_type()
|
|
|
|
|
let save_efm = &efm
|
|
|
|
|
|
|
|
|
|
" error type
|
|
|
|
|
set efm=%f:%l:%t:%m
|
2022-10-12 23:31:10 -07:00
|
|
|
|
let lines =<< trim END
|
|
|
|
|
Xfile1:10:E:msg1
|
|
|
|
|
Xfile1:20:W:msg2
|
|
|
|
|
Xfile1:30:I:msg3
|
|
|
|
|
Xfile1:40:N:msg4
|
|
|
|
|
Xfile1:50:R:msg5
|
|
|
|
|
END
|
|
|
|
|
cexpr lines
|
2021-01-01 21:13:10 -07:00
|
|
|
|
let output = split(execute('clist'), "\n")
|
|
|
|
|
call assert_equal([
|
|
|
|
|
\ ' 1 Xfile1:10 error: msg1',
|
|
|
|
|
\ ' 2 Xfile1:20 warning: msg2',
|
|
|
|
|
\ ' 3 Xfile1:30 info: msg3',
|
|
|
|
|
\ ' 4 Xfile1:40 note: msg4',
|
|
|
|
|
\ ' 5 Xfile1:50 R: msg5'], output)
|
|
|
|
|
|
|
|
|
|
" error type and a error number
|
|
|
|
|
set efm=%f:%l:%t:%n:%m
|
2022-10-12 23:31:10 -07:00
|
|
|
|
let lines =<< trim END
|
|
|
|
|
Xfile1:10:E:2:msg1
|
|
|
|
|
Xfile1:20:W:4:msg2
|
|
|
|
|
Xfile1:30:I:6:msg3
|
|
|
|
|
Xfile1:40:N:8:msg4
|
|
|
|
|
Xfile1:50:R:3:msg5
|
|
|
|
|
END
|
|
|
|
|
cexpr lines
|
2021-01-01 21:13:10 -07:00
|
|
|
|
let output = split(execute('clist'), "\n")
|
|
|
|
|
call assert_equal([
|
|
|
|
|
\ ' 1 Xfile1:10 error 2: msg1',
|
|
|
|
|
\ ' 2 Xfile1:20 warning 4: msg2',
|
|
|
|
|
\ ' 3 Xfile1:30 info 6: msg3',
|
|
|
|
|
\ ' 4 Xfile1:40 note 8: msg4',
|
|
|
|
|
\ ' 5 Xfile1:50 R 3: msg5'], output)
|
|
|
|
|
let &efm = save_efm
|
|
|
|
|
endfunc
|
|
|
|
|
|
2022-02-08 22:18:37 -07:00
|
|
|
|
" Test for end_lnum ('%e') and end_col ('%k') fields in 'efm'
|
|
|
|
|
func Test_efm_end_lnum_col()
|
|
|
|
|
let save_efm = &efm
|
|
|
|
|
|
|
|
|
|
" single line
|
|
|
|
|
set efm=%f:%l-%e:%c-%k:%t:%m
|
|
|
|
|
cexpr ["Xfile1:10-20:1-2:E:msg1", "Xfile1:20-30:2-3:W:msg2",]
|
|
|
|
|
let output = split(execute('clist'), "\n")
|
|
|
|
|
call assert_equal([
|
|
|
|
|
\ ' 1 Xfile1:10-20 col 1-2 error: msg1',
|
|
|
|
|
\ ' 2 Xfile1:20-30 col 2-3 warning: msg2'], output)
|
|
|
|
|
|
|
|
|
|
" multiple lines
|
|
|
|
|
set efm=%A%n)%m,%Z%f:%l-%e:%c-%k
|
2022-10-12 23:31:10 -07:00
|
|
|
|
let lines =<< trim END
|
|
|
|
|
1)msg1
|
|
|
|
|
Xfile1:14-24:1-2
|
|
|
|
|
2)msg2
|
|
|
|
|
Xfile1:24-34:3-4
|
|
|
|
|
END
|
|
|
|
|
cexpr lines
|
2022-02-08 22:18:37 -07:00
|
|
|
|
let output = split(execute('clist'), "\n")
|
|
|
|
|
call assert_equal([
|
|
|
|
|
\ ' 1 Xfile1:14-24 col 1-2 error 1: msg1',
|
|
|
|
|
\ ' 2 Xfile1:24-34 col 3-4 error 2: msg2'], output)
|
|
|
|
|
let &efm = save_efm
|
|
|
|
|
endfunc
|
|
|
|
|
|
2017-07-16 08:32:32 -07:00
|
|
|
|
func XquickfixChangedByAutocmd(cchar)
|
2016-12-12 13:05:34 -07:00
|
|
|
|
call s:setup_commands(a:cchar)
|
2016-12-13 12:15:10 -07:00
|
|
|
|
if a:cchar == 'c'
|
|
|
|
|
let ErrorNr = 'E925'
|
2017-07-16 08:32:32 -07:00
|
|
|
|
func! ReadFunc()
|
2016-12-13 12:15:10 -07:00
|
|
|
|
colder
|
|
|
|
|
cgetexpr []
|
|
|
|
|
endfunc
|
|
|
|
|
else
|
|
|
|
|
let ErrorNr = 'E926'
|
2017-07-16 08:32:32 -07:00
|
|
|
|
func! ReadFunc()
|
2016-12-13 12:15:10 -07:00
|
|
|
|
lolder
|
|
|
|
|
lgetexpr []
|
|
|
|
|
endfunc
|
|
|
|
|
endif
|
|
|
|
|
|
2022-10-12 19:13:17 -07:00
|
|
|
|
augroup QF_Test
|
2016-12-13 12:15:10 -07:00
|
|
|
|
au!
|
2016-12-12 09:33:51 -07:00
|
|
|
|
autocmd BufReadCmd test_changed.txt call ReadFunc()
|
2016-12-13 12:15:10 -07:00
|
|
|
|
augroup END
|
|
|
|
|
|
2016-12-12 09:33:51 -07:00
|
|
|
|
new | only
|
2016-12-13 12:15:10 -07:00
|
|
|
|
let words = [ "a", "b" ]
|
|
|
|
|
let qflist = []
|
|
|
|
|
for word in words
|
2016-12-12 09:33:51 -07:00
|
|
|
|
call add(qflist, {'filename': 'test_changed.txt'})
|
2016-12-12 13:05:34 -07:00
|
|
|
|
call g:Xsetlist(qflist, ' ')
|
2016-12-13 12:15:10 -07:00
|
|
|
|
endfor
|
2016-12-12 13:05:34 -07:00
|
|
|
|
call assert_fails('Xrewind', ErrorNr . ':')
|
2016-12-13 12:15:10 -07:00
|
|
|
|
|
2022-10-12 19:13:17 -07:00
|
|
|
|
augroup QF_Test
|
|
|
|
|
au!
|
|
|
|
|
augroup END
|
|
|
|
|
|
|
|
|
|
if a:cchar == 'c'
|
|
|
|
|
cexpr ["Xtest1:1:Line"]
|
|
|
|
|
cwindow
|
|
|
|
|
only
|
|
|
|
|
augroup QF_Test
|
|
|
|
|
au!
|
|
|
|
|
autocmd WinEnter * call setqflist([], 'f')
|
|
|
|
|
augroup END
|
|
|
|
|
call assert_fails('exe "normal \<CR>"', 'E925:')
|
|
|
|
|
augroup QF_Test
|
|
|
|
|
au!
|
|
|
|
|
augroup END
|
|
|
|
|
endif
|
|
|
|
|
%bw!
|
2016-12-13 12:15:10 -07:00
|
|
|
|
endfunc
|
|
|
|
|
|
2017-07-16 08:32:32 -07:00
|
|
|
|
func Test_quickfix_was_changed_by_autocmd()
|
2016-12-13 12:15:10 -07:00
|
|
|
|
call XquickfixChangedByAutocmd('c')
|
|
|
|
|
call XquickfixChangedByAutocmd('l')
|
2017-07-16 08:32:32 -07:00
|
|
|
|
endfunc
|
2016-12-13 12:15:10 -07:00
|
|
|
|
|
2020-09-13 13:59:07 -07:00
|
|
|
|
func Test_setloclist_in_autocommand()
|
|
|
|
|
call writefile(['test1', 'test2'], 'Xfile')
|
|
|
|
|
edit Xfile
|
|
|
|
|
let s:bufnr = bufnr()
|
|
|
|
|
call setloclist(1,
|
|
|
|
|
\ [{'bufnr' : s:bufnr, 'lnum' : 1, 'text' : 'test1'},
|
|
|
|
|
\ {'bufnr' : s:bufnr, 'lnum' : 2, 'text' : 'test2'}])
|
|
|
|
|
|
|
|
|
|
augroup Test_LocList
|
|
|
|
|
au!
|
|
|
|
|
autocmd BufEnter * call setloclist(1,
|
|
|
|
|
\ [{'bufnr' : s:bufnr, 'lnum' : 1, 'text' : 'test1'},
|
|
|
|
|
\ {'bufnr' : s:bufnr, 'lnum' : 2, 'text' : 'test2'}], 'r')
|
|
|
|
|
augroup END
|
|
|
|
|
|
|
|
|
|
lopen
|
|
|
|
|
call assert_fails('exe "normal j\<CR>"', 'E926:')
|
|
|
|
|
|
|
|
|
|
augroup Test_LocList
|
|
|
|
|
au!
|
|
|
|
|
augroup END
|
|
|
|
|
call delete('Xfile')
|
|
|
|
|
endfunc
|
|
|
|
|
|
2016-12-13 12:15:10 -07:00
|
|
|
|
func Test_caddbuffer_to_empty()
|
|
|
|
|
helpgr quickfix
|
|
|
|
|
call setqflist([], 'r')
|
|
|
|
|
cad
|
|
|
|
|
try
|
|
|
|
|
cn
|
|
|
|
|
catch
|
|
|
|
|
" number of matches is unknown
|
|
|
|
|
call assert_true(v:exception =~ 'E553:')
|
|
|
|
|
endtry
|
|
|
|
|
quit!
|
|
|
|
|
endfunc
|
|
|
|
|
|
|
|
|
|
func Test_cgetexpr_works()
|
|
|
|
|
" this must not crash Vim
|
|
|
|
|
cgetexpr [$x]
|
2016-12-12 13:05:34 -07:00
|
|
|
|
lgetexpr [$x]
|
2016-12-13 12:15:10 -07:00
|
|
|
|
endfunc
|
2016-12-12 08:56:00 -07:00
|
|
|
|
|
|
|
|
|
" Tests for the setqflist() and setloclist() functions
|
2017-07-16 08:32:32 -07:00
|
|
|
|
func SetXlistTests(cchar, bnum)
|
2016-12-12 13:05:34 -07:00
|
|
|
|
call s:setup_commands(a:cchar)
|
2016-12-12 08:56:00 -07:00
|
|
|
|
|
2016-12-12 13:05:34 -07:00
|
|
|
|
call g:Xsetlist([{'bufnr': a:bnum, 'lnum': 1},
|
2021-07-31 10:10:44 -07:00
|
|
|
|
\ {'bufnr': a:bnum, 'lnum': 2, 'end_lnum': 3, 'col': 4, 'end_col': 5}])
|
2016-12-12 13:05:34 -07:00
|
|
|
|
let l = g:Xgetlist()
|
2016-12-12 08:56:00 -07:00
|
|
|
|
call assert_equal(2, len(l))
|
|
|
|
|
call assert_equal(2, l[1].lnum)
|
2021-07-31 10:10:44 -07:00
|
|
|
|
call assert_equal(3, l[1].end_lnum)
|
|
|
|
|
call assert_equal(4, l[1].col)
|
|
|
|
|
call assert_equal(5, l[1].end_col)
|
2016-12-12 08:56:00 -07:00
|
|
|
|
|
2016-12-12 13:05:34 -07:00
|
|
|
|
Xnext
|
|
|
|
|
call g:Xsetlist([{'bufnr': a:bnum, 'lnum': 3}], 'a')
|
|
|
|
|
let l = g:Xgetlist()
|
2016-12-12 08:56:00 -07:00
|
|
|
|
call assert_equal(3, len(l))
|
2016-12-12 13:05:34 -07:00
|
|
|
|
Xnext
|
2016-12-12 08:56:00 -07:00
|
|
|
|
call assert_equal(3, line('.'))
|
|
|
|
|
|
2016-12-12 13:05:01 -07:00
|
|
|
|
" Appending entries to the list should not change the cursor position
|
|
|
|
|
" in the quickfix window
|
2016-12-12 13:05:34 -07:00
|
|
|
|
Xwindow
|
2016-12-12 13:05:01 -07:00
|
|
|
|
1
|
2016-12-12 13:05:34 -07:00
|
|
|
|
call g:Xsetlist([{'bufnr': a:bnum, 'lnum': 4},
|
2016-12-12 13:05:01 -07:00
|
|
|
|
\ {'bufnr': a:bnum, 'lnum': 5}], 'a')
|
|
|
|
|
call assert_equal(1, line('.'))
|
|
|
|
|
close
|
|
|
|
|
|
2016-12-12 13:05:34 -07:00
|
|
|
|
call g:Xsetlist([{'bufnr': a:bnum, 'lnum': 3},
|
2016-12-12 08:56:00 -07:00
|
|
|
|
\ {'bufnr': a:bnum, 'lnum': 4},
|
|
|
|
|
\ {'bufnr': a:bnum, 'lnum': 5}], 'r')
|
2016-12-12 13:05:34 -07:00
|
|
|
|
let l = g:Xgetlist()
|
2016-12-12 08:56:00 -07:00
|
|
|
|
call assert_equal(3, len(l))
|
|
|
|
|
call assert_equal(5, l[2].lnum)
|
|
|
|
|
|
2016-12-12 13:05:34 -07:00
|
|
|
|
call g:Xsetlist([])
|
|
|
|
|
let l = g:Xgetlist()
|
2016-12-12 08:56:00 -07:00
|
|
|
|
call assert_equal(0, len(l))
|
2017-12-17 18:56:01 -07:00
|
|
|
|
|
2017-12-18 19:40:34 -07:00
|
|
|
|
" Tests for setting the 'valid' flag
|
|
|
|
|
call g:Xsetlist([{'bufnr':a:bnum, 'lnum':4, 'valid':0}])
|
|
|
|
|
Xwindow
|
|
|
|
|
call assert_equal(1, winnr('$'))
|
|
|
|
|
let l = g:Xgetlist()
|
|
|
|
|
call g:Xsetlist(l)
|
|
|
|
|
call assert_equal(0, g:Xgetlist()[0].valid)
|
2019-11-11 22:24:25 -07:00
|
|
|
|
" Adding a non-valid entry should not mark the list as having valid entries
|
|
|
|
|
call g:Xsetlist([{'bufnr':a:bnum, 'lnum':5, 'valid':0}], 'a')
|
|
|
|
|
Xwindow
|
|
|
|
|
call assert_equal(1, winnr('$'))
|
|
|
|
|
|
|
|
|
|
" :cnext/:cprev should still work even with invalid entries in the list
|
|
|
|
|
let l = [{'bufnr' : a:bnum, 'lnum' : 1, 'text' : '1', 'valid' : 0},
|
|
|
|
|
\ {'bufnr' : a:bnum, 'lnum' : 2, 'text' : '2', 'valid' : 0}]
|
|
|
|
|
call g:Xsetlist(l)
|
|
|
|
|
Xnext
|
|
|
|
|
call assert_equal(2, g:Xgetlist({'idx' : 0}).idx)
|
|
|
|
|
Xprev
|
|
|
|
|
call assert_equal(1, g:Xgetlist({'idx' : 0}).idx)
|
|
|
|
|
" :cnext/:cprev should still work after appending invalid entries to an
|
|
|
|
|
" empty list
|
|
|
|
|
call g:Xsetlist([])
|
|
|
|
|
call g:Xsetlist(l, 'a')
|
|
|
|
|
Xnext
|
|
|
|
|
call assert_equal(2, g:Xgetlist({'idx' : 0}).idx)
|
|
|
|
|
Xprev
|
|
|
|
|
call assert_equal(1, g:Xgetlist({'idx' : 0}).idx)
|
|
|
|
|
|
2017-12-18 19:40:34 -07:00
|
|
|
|
call g:Xsetlist([{'text':'Text1', 'valid':1}])
|
|
|
|
|
Xwindow
|
|
|
|
|
call assert_equal(2, winnr('$'))
|
|
|
|
|
Xclose
|
|
|
|
|
let save_efm = &efm
|
|
|
|
|
set efm=%m
|
|
|
|
|
Xgetexpr 'TestMessage'
|
|
|
|
|
let l = g:Xgetlist()
|
|
|
|
|
call g:Xsetlist(l)
|
|
|
|
|
call assert_equal(1, g:Xgetlist()[0].valid)
|
|
|
|
|
let &efm = save_efm
|
|
|
|
|
|
2017-12-17 18:56:01 -07:00
|
|
|
|
" Error cases:
|
|
|
|
|
" Refer to a non-existing buffer and pass a non-dictionary type
|
|
|
|
|
call assert_fails("call g:Xsetlist([{'bufnr':998, 'lnum':4}," .
|
|
|
|
|
\ " {'bufnr':999, 'lnum':5}])", 'E92:')
|
|
|
|
|
call g:Xsetlist([[1, 2,3]])
|
|
|
|
|
call assert_equal(0, len(g:Xgetlist()))
|
2022-10-12 19:13:17 -07:00
|
|
|
|
call assert_fails('call g:Xsetlist([], [])', 'E928:')
|
|
|
|
|
call g:Xsetlist([v:_null_dict])
|
|
|
|
|
call assert_equal([], g:Xgetlist())
|
2017-07-16 08:32:32 -07:00
|
|
|
|
endfunc
|
2016-12-12 08:56:00 -07:00
|
|
|
|
|
2017-07-16 08:32:32 -07:00
|
|
|
|
func Test_setqflist()
|
2016-12-12 08:56:00 -07:00
|
|
|
|
new Xtestfile | only
|
|
|
|
|
let bnum = bufnr('%')
|
|
|
|
|
call setline(1, range(1,5))
|
|
|
|
|
|
|
|
|
|
call SetXlistTests('c', bnum)
|
|
|
|
|
call SetXlistTests('l', bnum)
|
|
|
|
|
|
2016-12-12 13:05:24 -07:00
|
|
|
|
enew!
|
2016-12-12 08:56:00 -07:00
|
|
|
|
call delete('Xtestfile')
|
2017-07-16 08:32:32 -07:00
|
|
|
|
endfunc
|
2016-12-12 09:33:51 -07:00
|
|
|
|
|
2017-07-16 08:32:32 -07:00
|
|
|
|
func Xlist_empty_middle(cchar)
|
2016-12-12 13:05:34 -07:00
|
|
|
|
call s:setup_commands(a:cchar)
|
|
|
|
|
|
2016-12-12 13:05:24 -07:00
|
|
|
|
" create three quickfix lists
|
2017-12-17 18:56:01 -07:00
|
|
|
|
let @/ = 'Test_'
|
|
|
|
|
Xvimgrep // test_quickfix.vim
|
2016-12-12 13:05:34 -07:00
|
|
|
|
let testlen = len(g:Xgetlist())
|
2016-12-12 13:05:24 -07:00
|
|
|
|
call assert_true(testlen > 0)
|
2016-12-12 13:05:34 -07:00
|
|
|
|
Xvimgrep empty test_quickfix.vim
|
|
|
|
|
call assert_true(len(g:Xgetlist()) > 0)
|
|
|
|
|
Xvimgrep matches test_quickfix.vim
|
|
|
|
|
let matchlen = len(g:Xgetlist())
|
2016-12-12 13:05:24 -07:00
|
|
|
|
call assert_true(matchlen > 0)
|
2016-12-12 13:05:34 -07:00
|
|
|
|
Xolder
|
2016-12-12 13:05:24 -07:00
|
|
|
|
" make the middle list empty
|
2016-12-12 13:05:34 -07:00
|
|
|
|
call g:Xsetlist([], 'r')
|
|
|
|
|
call assert_true(len(g:Xgetlist()) == 0)
|
|
|
|
|
Xolder
|
|
|
|
|
call assert_equal(testlen, len(g:Xgetlist()))
|
|
|
|
|
Xnewer
|
|
|
|
|
Xnewer
|
|
|
|
|
call assert_equal(matchlen, len(g:Xgetlist()))
|
2016-12-12 13:05:24 -07:00
|
|
|
|
endfunc
|
|
|
|
|
|
2017-07-16 08:32:32 -07:00
|
|
|
|
func Test_setqflist_empty_middle()
|
2016-12-12 13:05:34 -07:00
|
|
|
|
call Xlist_empty_middle('c')
|
|
|
|
|
call Xlist_empty_middle('l')
|
2017-07-16 08:32:32 -07:00
|
|
|
|
endfunc
|
2016-12-12 13:05:34 -07:00
|
|
|
|
|
2017-07-16 08:32:32 -07:00
|
|
|
|
func Xlist_empty_older(cchar)
|
2016-12-12 13:05:34 -07:00
|
|
|
|
call s:setup_commands(a:cchar)
|
|
|
|
|
|
2016-12-12 13:05:24 -07:00
|
|
|
|
" create three quickfix lists
|
2016-12-12 13:05:34 -07:00
|
|
|
|
Xvimgrep one test_quickfix.vim
|
|
|
|
|
let onelen = len(g:Xgetlist())
|
2016-12-12 13:05:24 -07:00
|
|
|
|
call assert_true(onelen > 0)
|
2016-12-12 13:05:34 -07:00
|
|
|
|
Xvimgrep two test_quickfix.vim
|
|
|
|
|
let twolen = len(g:Xgetlist())
|
2016-12-12 13:05:24 -07:00
|
|
|
|
call assert_true(twolen > 0)
|
2016-12-12 13:05:34 -07:00
|
|
|
|
Xvimgrep three test_quickfix.vim
|
|
|
|
|
let threelen = len(g:Xgetlist())
|
2016-12-12 13:05:24 -07:00
|
|
|
|
call assert_true(threelen > 0)
|
2016-12-12 13:05:34 -07:00
|
|
|
|
Xolder 2
|
2016-12-12 13:05:24 -07:00
|
|
|
|
" make the first list empty, check the others didn't change
|
2016-12-12 13:05:34 -07:00
|
|
|
|
call g:Xsetlist([], 'r')
|
|
|
|
|
call assert_true(len(g:Xgetlist()) == 0)
|
|
|
|
|
Xnewer
|
|
|
|
|
call assert_equal(twolen, len(g:Xgetlist()))
|
|
|
|
|
Xnewer
|
|
|
|
|
call assert_equal(threelen, len(g:Xgetlist()))
|
2017-07-16 08:32:32 -07:00
|
|
|
|
endfunc
|
2016-12-12 13:05:34 -07:00
|
|
|
|
|
2017-07-16 08:32:32 -07:00
|
|
|
|
func Test_setqflist_empty_older()
|
2016-12-12 13:05:34 -07:00
|
|
|
|
call Xlist_empty_older('c')
|
|
|
|
|
call Xlist_empty_older('l')
|
2017-07-16 08:32:32 -07:00
|
|
|
|
endfunc
|
2016-12-12 13:05:24 -07:00
|
|
|
|
|
2017-07-16 08:32:32 -07:00
|
|
|
|
func XquickfixSetListWithAct(cchar)
|
2016-12-12 13:05:34 -07:00
|
|
|
|
call s:setup_commands(a:cchar)
|
|
|
|
|
|
2016-12-12 09:33:51 -07:00
|
|
|
|
let list1 = [{'filename': 'fnameA', 'text': 'A'},
|
|
|
|
|
\ {'filename': 'fnameB', 'text': 'B'}]
|
|
|
|
|
let list2 = [{'filename': 'fnameC', 'text': 'C'},
|
|
|
|
|
\ {'filename': 'fnameD', 'text': 'D'},
|
|
|
|
|
\ {'filename': 'fnameE', 'text': 'E'}]
|
|
|
|
|
|
2021-12-19 00:46:28 -07:00
|
|
|
|
" {action} is unspecified. Same as specifying ' '.
|
2016-12-12 09:33:51 -07:00
|
|
|
|
new | only
|
2016-12-12 13:05:34 -07:00
|
|
|
|
silent! Xnewer 99
|
|
|
|
|
call g:Xsetlist(list1)
|
|
|
|
|
call g:Xsetlist(list2)
|
|
|
|
|
let li = g:Xgetlist()
|
2016-12-12 09:33:51 -07:00
|
|
|
|
call assert_equal(3, len(li))
|
|
|
|
|
call assert_equal('C', li[0]['text'])
|
|
|
|
|
call assert_equal('D', li[1]['text'])
|
|
|
|
|
call assert_equal('E', li[2]['text'])
|
2016-12-12 13:05:34 -07:00
|
|
|
|
silent! Xolder
|
|
|
|
|
let li = g:Xgetlist()
|
2016-12-12 09:33:51 -07:00
|
|
|
|
call assert_equal(2, len(li))
|
|
|
|
|
call assert_equal('A', li[0]['text'])
|
|
|
|
|
call assert_equal('B', li[1]['text'])
|
|
|
|
|
|
|
|
|
|
" {action} is specified ' '.
|
|
|
|
|
new | only
|
2016-12-12 13:05:34 -07:00
|
|
|
|
silent! Xnewer 99
|
|
|
|
|
call g:Xsetlist(list1)
|
|
|
|
|
call g:Xsetlist(list2, ' ')
|
|
|
|
|
let li = g:Xgetlist()
|
2016-12-12 09:33:51 -07:00
|
|
|
|
call assert_equal(3, len(li))
|
|
|
|
|
call assert_equal('C', li[0]['text'])
|
|
|
|
|
call assert_equal('D', li[1]['text'])
|
|
|
|
|
call assert_equal('E', li[2]['text'])
|
2016-12-12 13:05:34 -07:00
|
|
|
|
silent! Xolder
|
|
|
|
|
let li = g:Xgetlist()
|
2016-12-12 09:33:51 -07:00
|
|
|
|
call assert_equal(2, len(li))
|
|
|
|
|
call assert_equal('A', li[0]['text'])
|
|
|
|
|
call assert_equal('B', li[1]['text'])
|
|
|
|
|
|
|
|
|
|
" {action} is specified 'a'.
|
|
|
|
|
new | only
|
2016-12-12 13:05:34 -07:00
|
|
|
|
silent! Xnewer 99
|
|
|
|
|
call g:Xsetlist(list1)
|
|
|
|
|
call g:Xsetlist(list2, 'a')
|
|
|
|
|
let li = g:Xgetlist()
|
2016-12-12 09:33:51 -07:00
|
|
|
|
call assert_equal(5, len(li))
|
|
|
|
|
call assert_equal('A', li[0]['text'])
|
|
|
|
|
call assert_equal('B', li[1]['text'])
|
|
|
|
|
call assert_equal('C', li[2]['text'])
|
|
|
|
|
call assert_equal('D', li[3]['text'])
|
|
|
|
|
call assert_equal('E', li[4]['text'])
|
|
|
|
|
|
|
|
|
|
" {action} is specified 'r'.
|
|
|
|
|
new | only
|
2016-12-12 13:05:34 -07:00
|
|
|
|
silent! Xnewer 99
|
|
|
|
|
call g:Xsetlist(list1)
|
|
|
|
|
call g:Xsetlist(list2, 'r')
|
|
|
|
|
let li = g:Xgetlist()
|
2016-12-12 09:33:51 -07:00
|
|
|
|
call assert_equal(3, len(li))
|
|
|
|
|
call assert_equal('C', li[0]['text'])
|
|
|
|
|
call assert_equal('D', li[1]['text'])
|
|
|
|
|
call assert_equal('E', li[2]['text'])
|
|
|
|
|
|
|
|
|
|
" Test for wrong value.
|
|
|
|
|
new | only
|
2016-12-12 13:05:34 -07:00
|
|
|
|
call assert_fails("call g:Xsetlist(0)", 'E714:')
|
|
|
|
|
call assert_fails("call g:Xsetlist(list1, '')", 'E927:')
|
|
|
|
|
call assert_fails("call g:Xsetlist(list1, 'aa')", 'E927:')
|
|
|
|
|
call assert_fails("call g:Xsetlist(list1, ' a')", 'E927:')
|
|
|
|
|
call assert_fails("call g:Xsetlist(list1, 0)", 'E928:')
|
2016-12-12 09:33:51 -07:00
|
|
|
|
endfunc
|
|
|
|
|
|
2019-04-16 20:57:12 -07:00
|
|
|
|
func Test_setqflist_invalid_nr()
|
|
|
|
|
" The following command used to crash Vim
|
2021-10-31 11:10:46 -07:00
|
|
|
|
eval []->setqflist(' ', {'nr' : $XXX_DOES_NOT_EXIST})
|
2019-04-16 20:57:12 -07:00
|
|
|
|
endfunc
|
|
|
|
|
|
2020-02-10 17:55:59 -07:00
|
|
|
|
func Test_setqflist_user_sets_buftype()
|
|
|
|
|
call setqflist([{'text': 'foo'}, {'text': 'bar'}])
|
|
|
|
|
set buftype=quickfix
|
|
|
|
|
call setqflist([], 'a')
|
|
|
|
|
enew
|
|
|
|
|
endfunc
|
|
|
|
|
|
2017-07-16 08:32:32 -07:00
|
|
|
|
func Test_quickfix_set_list_with_act()
|
2016-12-12 09:33:51 -07:00
|
|
|
|
call XquickfixSetListWithAct('c')
|
|
|
|
|
call XquickfixSetListWithAct('l')
|
2017-07-16 08:32:32 -07:00
|
|
|
|
endfunc
|
2016-12-12 13:04:44 -07:00
|
|
|
|
|
2017-07-16 08:32:32 -07:00
|
|
|
|
func XLongLinesTests(cchar)
|
2016-12-12 13:05:34 -07:00
|
|
|
|
let l = g:Xgetlist()
|
2016-12-12 13:04:44 -07:00
|
|
|
|
|
2016-12-12 13:05:47 -07:00
|
|
|
|
call assert_equal(4, len(l))
|
2016-12-12 13:04:44 -07:00
|
|
|
|
call assert_equal(1, l[0].lnum)
|
|
|
|
|
call assert_equal(1, l[0].col)
|
2016-12-12 13:05:47 -07:00
|
|
|
|
call assert_equal(1975, len(l[0].text))
|
2016-12-12 13:04:44 -07:00
|
|
|
|
call assert_equal(2, l[1].lnum)
|
|
|
|
|
call assert_equal(1, l[1].col)
|
|
|
|
|
call assert_equal(4070, len(l[1].text))
|
|
|
|
|
call assert_equal(3, l[2].lnum)
|
|
|
|
|
call assert_equal(1, l[2].col)
|
2016-12-12 13:05:47 -07:00
|
|
|
|
call assert_equal(4070, len(l[2].text))
|
|
|
|
|
call assert_equal(4, l[3].lnum)
|
|
|
|
|
call assert_equal(1, l[3].col)
|
|
|
|
|
call assert_equal(10, len(l[3].text))
|
2016-12-12 13:04:44 -07:00
|
|
|
|
|
2016-12-12 13:05:34 -07:00
|
|
|
|
call g:Xsetlist([], 'r')
|
2017-07-16 08:32:32 -07:00
|
|
|
|
endfunc
|
2016-12-12 13:05:34 -07:00
|
|
|
|
|
2017-07-16 08:32:32 -07:00
|
|
|
|
func s:long_lines_tests(cchar)
|
2016-12-12 13:05:34 -07:00
|
|
|
|
call s:setup_commands(a:cchar)
|
2016-12-12 13:04:44 -07:00
|
|
|
|
|
|
|
|
|
let testfile = 'samples/quickfix.txt'
|
|
|
|
|
|
|
|
|
|
" file
|
2016-12-12 13:05:34 -07:00
|
|
|
|
exe 'Xgetfile' testfile
|
|
|
|
|
call XLongLinesTests(a:cchar)
|
2016-12-12 13:04:44 -07:00
|
|
|
|
|
|
|
|
|
" list
|
2016-12-12 13:05:34 -07:00
|
|
|
|
Xexpr readfile(testfile)
|
|
|
|
|
call XLongLinesTests(a:cchar)
|
2016-12-12 13:04:44 -07:00
|
|
|
|
|
|
|
|
|
" string
|
2016-12-12 13:05:34 -07:00
|
|
|
|
Xexpr join(readfile(testfile), "\n")
|
|
|
|
|
call XLongLinesTests(a:cchar)
|
2016-12-12 13:04:44 -07:00
|
|
|
|
|
|
|
|
|
" buffer
|
2016-12-12 13:05:34 -07:00
|
|
|
|
exe 'edit' testfile
|
|
|
|
|
exe 'Xbuffer' bufnr('%')
|
2016-12-12 13:05:43 -07:00
|
|
|
|
call XLongLinesTests(a:cchar)
|
2017-07-16 08:32:32 -07:00
|
|
|
|
endfunc
|
2016-12-12 13:05:34 -07:00
|
|
|
|
|
2017-07-16 08:32:32 -07:00
|
|
|
|
func Test_long_lines()
|
2016-12-12 13:05:34 -07:00
|
|
|
|
call s:long_lines_tests('c')
|
|
|
|
|
call s:long_lines_tests('l')
|
2017-07-16 08:32:32 -07:00
|
|
|
|
endfunc
|
2016-12-12 13:05:47 -07:00
|
|
|
|
|
2020-10-06 20:14:41 -07:00
|
|
|
|
func Test_cgetfile_on_long_lines()
|
|
|
|
|
" Problematic values if the line is longer than 4096 bytes. Then 1024 bytes
|
|
|
|
|
" are read at a time.
|
|
|
|
|
for len in [4078, 4079, 4080, 5102, 5103, 5104, 6126, 6127, 6128, 7150, 7151, 7152]
|
2022-10-12 23:31:10 -07:00
|
|
|
|
let lines =<< trim END
|
|
|
|
|
/tmp/file1:1:1:aaa
|
|
|
|
|
/tmp/file2:1:1:%s
|
|
|
|
|
/tmp/file3:1:1:bbb
|
|
|
|
|
/tmp/file4:1:1:ccc
|
|
|
|
|
END
|
2020-10-06 20:14:41 -07:00
|
|
|
|
let lines[1] = substitute(lines[1], '%s', repeat('x', len), '')
|
|
|
|
|
call writefile(lines, 'Xcqetfile.txt')
|
|
|
|
|
cgetfile Xcqetfile.txt
|
|
|
|
|
call assert_equal(4, getqflist(#{size: v:true}).size, 'with length ' .. len)
|
|
|
|
|
endfor
|
|
|
|
|
call delete('Xcqetfile.txt')
|
|
|
|
|
endfunc
|
|
|
|
|
|
2017-07-16 08:32:32 -07:00
|
|
|
|
func s:create_test_file(filename)
|
2016-12-12 13:05:47 -07:00
|
|
|
|
let l = []
|
|
|
|
|
for i in range(1, 20)
|
|
|
|
|
call add(l, 'Line' . i)
|
|
|
|
|
endfor
|
|
|
|
|
call writefile(l, a:filename)
|
2017-07-16 08:32:32 -07:00
|
|
|
|
endfunc
|
2016-12-12 13:05:47 -07:00
|
|
|
|
|
2017-07-16 08:32:32 -07:00
|
|
|
|
func Test_switchbuf()
|
2016-12-12 13:05:47 -07:00
|
|
|
|
call s:create_test_file('Xqftestfile1')
|
|
|
|
|
call s:create_test_file('Xqftestfile2')
|
|
|
|
|
call s:create_test_file('Xqftestfile3')
|
|
|
|
|
|
|
|
|
|
new | only
|
|
|
|
|
edit Xqftestfile1
|
|
|
|
|
let file1_winid = win_getid()
|
|
|
|
|
new Xqftestfile2
|
|
|
|
|
let file2_winid = win_getid()
|
2022-10-12 23:31:10 -07:00
|
|
|
|
let lines =<< trim END
|
|
|
|
|
Xqftestfile1:5:Line5
|
|
|
|
|
Xqftestfile1:6:Line6
|
|
|
|
|
Xqftestfile2:10:Line10
|
|
|
|
|
Xqftestfile2:11:Line11
|
|
|
|
|
Xqftestfile3:15:Line15
|
|
|
|
|
Xqftestfile3:16:Line16
|
|
|
|
|
END
|
|
|
|
|
cgetexpr lines
|
2016-12-12 13:05:47 -07:00
|
|
|
|
|
|
|
|
|
new
|
|
|
|
|
let winid = win_getid()
|
|
|
|
|
cfirst | cnext
|
|
|
|
|
call assert_equal(winid, win_getid())
|
2017-12-18 19:37:11 -07:00
|
|
|
|
2cnext
|
2016-12-12 13:05:47 -07:00
|
|
|
|
call assert_equal(winid, win_getid())
|
2017-12-18 19:37:11 -07:00
|
|
|
|
2cnext
|
2016-12-12 13:05:47 -07:00
|
|
|
|
call assert_equal(winid, win_getid())
|
|
|
|
|
|
2021-05-20 15:05:39 -07:00
|
|
|
|
" Test for 'switchbuf' set to search for files in windows in the current
|
|
|
|
|
" tabpage and jump to an existing window (if present)
|
2016-12-12 13:05:47 -07:00
|
|
|
|
set switchbuf=useopen
|
2021-05-20 15:05:39 -07:00
|
|
|
|
enew
|
2016-12-12 13:05:47 -07:00
|
|
|
|
cfirst | cnext
|
|
|
|
|
call assert_equal(file1_winid, win_getid())
|
2017-12-18 19:37:11 -07:00
|
|
|
|
2cnext
|
2016-12-12 13:05:47 -07:00
|
|
|
|
call assert_equal(file2_winid, win_getid())
|
2017-12-18 19:37:11 -07:00
|
|
|
|
2cnext
|
2016-12-12 13:05:47 -07:00
|
|
|
|
call assert_equal(file2_winid, win_getid())
|
|
|
|
|
|
2021-05-20 15:05:39 -07:00
|
|
|
|
" Test for 'switchbuf' set to search for files in tabpages and jump to an
|
|
|
|
|
" existing tabpage (if present)
|
2016-12-12 13:05:47 -07:00
|
|
|
|
enew | only
|
|
|
|
|
set switchbuf=usetab
|
|
|
|
|
tabedit Xqftestfile1
|
|
|
|
|
tabedit Xqftestfile2
|
2019-06-05 19:52:38 -07:00
|
|
|
|
tabedit Xqftestfile3
|
2016-12-12 13:05:47 -07:00
|
|
|
|
tabfirst
|
|
|
|
|
cfirst | cnext
|
|
|
|
|
call assert_equal(2, tabpagenr())
|
2017-12-18 19:37:11 -07:00
|
|
|
|
2cnext
|
2016-12-12 13:05:47 -07:00
|
|
|
|
call assert_equal(3, tabpagenr())
|
2019-06-05 19:52:38 -07:00
|
|
|
|
6cnext
|
|
|
|
|
call assert_equal(4, tabpagenr())
|
|
|
|
|
2cpfile
|
|
|
|
|
call assert_equal(2, tabpagenr())
|
|
|
|
|
2cnfile
|
|
|
|
|
call assert_equal(4, tabpagenr())
|
2016-12-12 13:05:47 -07:00
|
|
|
|
tabfirst | tabonly | enew
|
|
|
|
|
|
2021-05-20 15:05:39 -07:00
|
|
|
|
" Test for 'switchbuf' set to open a new window for every file
|
2016-12-12 13:05:47 -07:00
|
|
|
|
set switchbuf=split
|
|
|
|
|
cfirst | cnext
|
|
|
|
|
call assert_equal(1, winnr('$'))
|
|
|
|
|
cnext | cnext
|
|
|
|
|
call assert_equal(2, winnr('$'))
|
|
|
|
|
cnext | cnext
|
|
|
|
|
call assert_equal(3, winnr('$'))
|
|
|
|
|
|
2021-05-20 15:05:39 -07:00
|
|
|
|
" Test for 'switchbuf' set to open a new tabpage for every file
|
2016-12-12 13:05:47 -07:00
|
|
|
|
set switchbuf=newtab
|
2021-05-20 15:05:39 -07:00
|
|
|
|
enew | only
|
2016-12-12 13:05:47 -07:00
|
|
|
|
cfirst | cnext
|
|
|
|
|
call assert_equal(1, tabpagenr('$'))
|
|
|
|
|
cnext | cnext
|
|
|
|
|
call assert_equal(2, tabpagenr('$'))
|
|
|
|
|
cnext | cnext
|
|
|
|
|
call assert_equal(3, tabpagenr('$'))
|
|
|
|
|
tabfirst | enew | tabonly | only
|
|
|
|
|
|
2019-11-29 10:57:27 -07:00
|
|
|
|
set switchbuf=uselast
|
|
|
|
|
split
|
|
|
|
|
let last_winid = win_getid()
|
|
|
|
|
copen
|
|
|
|
|
exe "normal 1G\<CR>"
|
|
|
|
|
call assert_equal(last_winid, win_getid())
|
|
|
|
|
enew | only
|
|
|
|
|
|
2021-05-20 15:05:39 -07:00
|
|
|
|
" With an empty 'switchbuf', jumping to a quickfix entry should open the
|
|
|
|
|
" file in an existing window (if present)
|
2016-12-12 13:05:47 -07:00
|
|
|
|
set switchbuf=
|
|
|
|
|
edit Xqftestfile1
|
|
|
|
|
let file1_winid = win_getid()
|
|
|
|
|
new Xqftestfile2
|
|
|
|
|
let file2_winid = win_getid()
|
|
|
|
|
copen
|
|
|
|
|
exe "normal 1G\<CR>"
|
|
|
|
|
call assert_equal(file1_winid, win_getid())
|
|
|
|
|
copen
|
|
|
|
|
exe "normal 3G\<CR>"
|
|
|
|
|
call assert_equal(file2_winid, win_getid())
|
|
|
|
|
copen | only
|
|
|
|
|
exe "normal 5G\<CR>"
|
|
|
|
|
call assert_equal(2, winnr('$'))
|
|
|
|
|
call assert_equal(1, bufwinnr('Xqftestfile3'))
|
|
|
|
|
|
2017-12-17 18:51:51 -07:00
|
|
|
|
" If only quickfix window is open in the current tabpage, jumping to an
|
2020-10-20 21:03:36 -07:00
|
|
|
|
" entry with 'switchbuf' set to 'usetab' should search in other tabpages.
|
2016-12-12 13:05:47 -07:00
|
|
|
|
enew | only
|
2017-12-17 18:51:51 -07:00
|
|
|
|
set switchbuf=usetab
|
|
|
|
|
tabedit Xqftestfile1
|
|
|
|
|
tabedit Xqftestfile2
|
|
|
|
|
tabedit Xqftestfile3
|
|
|
|
|
tabfirst
|
|
|
|
|
copen | only
|
|
|
|
|
clast
|
|
|
|
|
call assert_equal(4, tabpagenr())
|
|
|
|
|
tabfirst | tabonly | enew | only
|
2016-12-12 13:05:47 -07:00
|
|
|
|
|
2021-05-20 15:05:39 -07:00
|
|
|
|
" Jumping to a file that is not present in any of the tabpages and the
|
|
|
|
|
" current tabpage doesn't have any usable windows, should open it in a new
|
|
|
|
|
" window in the current tabpage.
|
|
|
|
|
copen | only
|
|
|
|
|
cfirst
|
|
|
|
|
call assert_equal(1, tabpagenr())
|
2022-07-16 18:10:25 -07:00
|
|
|
|
call assert_equal('Xqftestfile1', @%)
|
2021-05-20 15:05:39 -07:00
|
|
|
|
|
|
|
|
|
" If opening a file changes 'switchbuf', then the new value should be
|
|
|
|
|
" retained.
|
2022-02-03 18:23:54 -07:00
|
|
|
|
set modeline&vim
|
2021-05-20 15:05:39 -07:00
|
|
|
|
call writefile(["vim: switchbuf=split"], 'Xqftestfile1')
|
|
|
|
|
enew | only
|
|
|
|
|
set switchbuf&vim
|
|
|
|
|
cexpr "Xqftestfile1:1:10"
|
|
|
|
|
call assert_equal('split', &switchbuf)
|
|
|
|
|
call writefile(["vim: switchbuf=usetab"], 'Xqftestfile1')
|
|
|
|
|
enew | only
|
|
|
|
|
set switchbuf=useopen
|
|
|
|
|
cexpr "Xqftestfile1:1:10"
|
|
|
|
|
call assert_equal('usetab', &switchbuf)
|
|
|
|
|
call writefile(["vim: switchbuf&vim"], 'Xqftestfile1')
|
|
|
|
|
enew | only
|
|
|
|
|
set switchbuf=useopen
|
|
|
|
|
cexpr "Xqftestfile1:1:10"
|
2021-08-16 11:20:46 -07:00
|
|
|
|
call assert_equal('uselast', &switchbuf)
|
2021-05-20 15:05:39 -07:00
|
|
|
|
|
2016-12-12 13:05:47 -07:00
|
|
|
|
call delete('Xqftestfile1')
|
|
|
|
|
call delete('Xqftestfile2')
|
|
|
|
|
call delete('Xqftestfile3')
|
2017-12-17 18:51:51 -07:00
|
|
|
|
set switchbuf&vim
|
|
|
|
|
|
|
|
|
|
enew | only
|
2017-07-16 08:32:32 -07:00
|
|
|
|
endfunc
|
2016-12-12 13:05:47 -07:00
|
|
|
|
|
2017-07-16 08:32:32 -07:00
|
|
|
|
func Xadjust_qflnum(cchar)
|
2016-12-12 13:05:47 -07:00
|
|
|
|
call s:setup_commands(a:cchar)
|
|
|
|
|
|
|
|
|
|
enew | only
|
|
|
|
|
|
2017-01-17 21:13:51 -07:00
|
|
|
|
let fname = 'Xqftestfile' . a:cchar
|
|
|
|
|
call s:create_test_file(fname)
|
|
|
|
|
exe 'edit ' . fname
|
2016-12-12 13:05:47 -07:00
|
|
|
|
|
2017-01-17 21:13:51 -07:00
|
|
|
|
Xgetexpr [fname . ':5:Line5',
|
|
|
|
|
\ fname . ':10:Line10',
|
|
|
|
|
\ fname . ':15:Line15',
|
|
|
|
|
\ fname . ':20:Line20']
|
2016-12-12 13:05:47 -07:00
|
|
|
|
|
|
|
|
|
6,14delete
|
|
|
|
|
call append(6, ['Buffer', 'Window'])
|
|
|
|
|
|
|
|
|
|
let l = g:Xgetlist()
|
|
|
|
|
call assert_equal(5, l[0].lnum)
|
|
|
|
|
call assert_equal(6, l[2].lnum)
|
|
|
|
|
call assert_equal(13, l[3].lnum)
|
|
|
|
|
|
2021-05-20 15:05:39 -07:00
|
|
|
|
" If a file doesn't have any quickfix entries, then deleting lines in the
|
|
|
|
|
" file should not update the quickfix list
|
|
|
|
|
call g:Xsetlist([], 'f')
|
|
|
|
|
1,2delete
|
|
|
|
|
call assert_equal([], g:Xgetlist())
|
|
|
|
|
|
2016-12-12 13:05:47 -07:00
|
|
|
|
enew!
|
2017-01-17 21:13:51 -07:00
|
|
|
|
call delete(fname)
|
2017-07-16 08:32:32 -07:00
|
|
|
|
endfunc
|
2016-12-12 13:05:47 -07:00
|
|
|
|
|
2017-07-16 08:32:32 -07:00
|
|
|
|
func Test_adjust_lnum()
|
2017-01-17 21:13:51 -07:00
|
|
|
|
call setloclist(0, [])
|
2016-12-12 13:05:47 -07:00
|
|
|
|
call Xadjust_qflnum('c')
|
2017-01-17 21:13:51 -07:00
|
|
|
|
call setqflist([])
|
2016-12-12 13:05:47 -07:00
|
|
|
|
call Xadjust_qflnum('l')
|
2017-07-16 08:32:32 -07:00
|
|
|
|
endfunc
|
2016-12-12 13:05:47 -07:00
|
|
|
|
|
|
|
|
|
" Tests for the :grep/:lgrep and :grepadd/:lgrepadd commands
|
2017-07-16 08:32:32 -07:00
|
|
|
|
func s:test_xgrep(cchar)
|
2016-12-12 13:05:47 -07:00
|
|
|
|
call s:setup_commands(a:cchar)
|
|
|
|
|
|
|
|
|
|
" The following lines are used for the grep test. Don't remove.
|
|
|
|
|
" Grep_Test_Text: Match 1
|
|
|
|
|
" Grep_Test_Text: Match 2
|
|
|
|
|
" GrepAdd_Test_Text: Match 1
|
|
|
|
|
" GrepAdd_Test_Text: Match 2
|
|
|
|
|
enew! | only
|
|
|
|
|
set makeef&vim
|
|
|
|
|
silent Xgrep Grep_Test_Text: test_quickfix.vim
|
2021-01-01 11:10:08 -07:00
|
|
|
|
call assert_true(len(g:Xgetlist()) == 5)
|
2016-12-12 13:05:47 -07:00
|
|
|
|
Xopen
|
|
|
|
|
call assert_true(w:quickfix_title =~ '^:grep')
|
|
|
|
|
Xclose
|
|
|
|
|
enew
|
|
|
|
|
set makeef=Temp_File_##
|
|
|
|
|
silent Xgrepadd GrepAdd_Test_Text: test_quickfix.vim
|
2022-02-14 01:17:11 -07:00
|
|
|
|
call assert_true(len(g:Xgetlist()) == 9)
|
2021-01-01 11:10:08 -07:00
|
|
|
|
|
|
|
|
|
" Try with 'grepprg' set to 'internal'
|
|
|
|
|
set grepprg=internal
|
|
|
|
|
silent Xgrep Grep_Test_Text: test_quickfix.vim
|
|
|
|
|
silent Xgrepadd GrepAdd_Test_Text: test_quickfix.vim
|
|
|
|
|
call assert_true(len(g:Xgetlist()) == 9)
|
|
|
|
|
set grepprg&vim
|
|
|
|
|
|
2022-02-14 01:17:11 -07:00
|
|
|
|
call writefile(['Vim'], 'XtestTempFile')
|
|
|
|
|
set makeef=XtestTempFile
|
|
|
|
|
silent Xgrep Grep_Test_Text: test_quickfix.vim
|
|
|
|
|
call assert_equal(5, len(g:Xgetlist()))
|
|
|
|
|
call assert_false(filereadable('XtestTempFile'))
|
|
|
|
|
set makeef&vim
|
2017-07-16 08:32:32 -07:00
|
|
|
|
endfunc
|
2016-12-12 13:05:47 -07:00
|
|
|
|
|
2017-07-16 08:32:32 -07:00
|
|
|
|
func Test_grep()
|
2016-12-12 13:05:47 -07:00
|
|
|
|
if !has('unix')
|
|
|
|
|
" The grepprg may not be set on non-Unix systems
|
|
|
|
|
return
|
|
|
|
|
endif
|
|
|
|
|
|
|
|
|
|
call s:test_xgrep('c')
|
|
|
|
|
call s:test_xgrep('l')
|
2017-07-16 08:32:32 -07:00
|
|
|
|
endfunc
|
2016-12-14 08:55:21 -07:00
|
|
|
|
|
2017-07-16 08:32:32 -07:00
|
|
|
|
func Test_two_windows()
|
2016-12-14 08:55:21 -07:00
|
|
|
|
" Use one 'errorformat' for two windows. Add an expression to each of them,
|
|
|
|
|
" make sure they each keep their own state.
|
|
|
|
|
set efm=%DEntering\ dir\ '%f',%f:%l:%m,%XLeaving\ dir\ '%f'
|
|
|
|
|
call mkdir('Xone/a', 'p')
|
|
|
|
|
call mkdir('Xtwo/a', 'p')
|
|
|
|
|
let lines = ['1', '2', 'one one one', '4', 'two two two', '6', '7']
|
|
|
|
|
call writefile(lines, 'Xone/a/one.txt')
|
|
|
|
|
call writefile(lines, 'Xtwo/a/two.txt')
|
|
|
|
|
|
|
|
|
|
new one
|
|
|
|
|
let one_id = win_getid()
|
|
|
|
|
lexpr ""
|
|
|
|
|
new two
|
|
|
|
|
let two_id = win_getid()
|
|
|
|
|
lexpr ""
|
|
|
|
|
|
|
|
|
|
laddexpr "Entering dir 'Xtwo/a'"
|
|
|
|
|
call win_gotoid(one_id)
|
|
|
|
|
laddexpr "Entering dir 'Xone/a'"
|
|
|
|
|
call win_gotoid(two_id)
|
|
|
|
|
laddexpr 'two.txt:5:two two two'
|
|
|
|
|
call win_gotoid(one_id)
|
|
|
|
|
laddexpr 'one.txt:3:one one one'
|
|
|
|
|
|
|
|
|
|
let loc_one = getloclist(one_id)
|
2022-06-25 14:31:27 -07:00
|
|
|
|
call assert_equal('Xone/a/one.txt', bufname(loc_one[1].bufnr))
|
2016-12-14 08:55:21 -07:00
|
|
|
|
call assert_equal(3, loc_one[1].lnum)
|
|
|
|
|
|
|
|
|
|
let loc_two = getloclist(two_id)
|
2022-06-25 14:31:27 -07:00
|
|
|
|
call assert_equal('Xtwo/a/two.txt', bufname(loc_two[1].bufnr))
|
2016-12-14 08:55:21 -07:00
|
|
|
|
call assert_equal(5, loc_two[1].lnum)
|
|
|
|
|
|
|
|
|
|
call win_gotoid(one_id)
|
|
|
|
|
bwipe!
|
|
|
|
|
call win_gotoid(two_id)
|
|
|
|
|
bwipe!
|
|
|
|
|
call delete('Xone', 'rf')
|
|
|
|
|
call delete('Xtwo', 'rf')
|
|
|
|
|
endfunc
|
2016-12-14 12:36:38 -07:00
|
|
|
|
|
2017-07-16 08:32:32 -07:00
|
|
|
|
func XbottomTests(cchar)
|
2016-12-14 13:33:06 -07:00
|
|
|
|
call s:setup_commands(a:cchar)
|
|
|
|
|
|
2017-12-18 12:26:49 -07:00
|
|
|
|
" Calling lbottom without any errors should fail
|
|
|
|
|
if a:cchar == 'l'
|
|
|
|
|
call assert_fails('lbottom', 'E776:')
|
|
|
|
|
endif
|
|
|
|
|
|
2017-12-30 21:39:51 -07:00
|
|
|
|
call g:Xsetlist([{'filename': 'foo', 'lnum': 42}])
|
2016-12-14 13:33:06 -07:00
|
|
|
|
Xopen
|
2016-12-14 12:36:38 -07:00
|
|
|
|
let wid = win_getid()
|
|
|
|
|
call assert_equal(1, line('.'))
|
|
|
|
|
wincmd w
|
2017-12-30 21:39:51 -07:00
|
|
|
|
call g:Xsetlist([{'filename': 'var', 'lnum': 24}], 'a')
|
2016-12-14 13:33:06 -07:00
|
|
|
|
Xbottom
|
2016-12-14 12:36:38 -07:00
|
|
|
|
call win_gotoid(wid)
|
|
|
|
|
call assert_equal(2, line('.'))
|
2016-12-14 13:33:06 -07:00
|
|
|
|
Xclose
|
2016-12-14 12:36:38 -07:00
|
|
|
|
endfunc
|
2016-12-14 13:33:06 -07:00
|
|
|
|
|
|
|
|
|
" Tests for the :cbottom and :lbottom commands
|
2017-07-16 08:32:32 -07:00
|
|
|
|
func Test_cbottom()
|
2016-12-14 13:33:06 -07:00
|
|
|
|
call XbottomTests('c')
|
|
|
|
|
call XbottomTests('l')
|
2017-07-16 08:32:32 -07:00
|
|
|
|
endfunc
|
2017-01-17 00:36:00 -07:00
|
|
|
|
|
2017-07-16 08:32:32 -07:00
|
|
|
|
func HistoryTest(cchar)
|
2017-01-17 00:36:00 -07:00
|
|
|
|
call s:setup_commands(a:cchar)
|
|
|
|
|
|
|
|
|
|
" clear all lists after the first one, then replace the first one.
|
|
|
|
|
call g:Xsetlist([])
|
2017-12-18 12:26:49 -07:00
|
|
|
|
call assert_fails('Xolder 99', 'E380:')
|
2017-01-17 00:36:00 -07:00
|
|
|
|
let entry = {'filename': 'foo', 'lnum': 42}
|
|
|
|
|
call g:Xsetlist([entry], 'r')
|
|
|
|
|
call g:Xsetlist([entry, entry])
|
|
|
|
|
call g:Xsetlist([entry, entry, entry])
|
|
|
|
|
let res = split(execute(a:cchar . 'hist'), "\n")
|
|
|
|
|
call assert_equal(3, len(res))
|
|
|
|
|
let common = 'errors :set' . (a:cchar == 'c' ? 'qf' : 'loc') . 'list()'
|
|
|
|
|
call assert_equal(' error list 1 of 3; 1 ' . common, res[0])
|
|
|
|
|
call assert_equal(' error list 2 of 3; 2 ' . common, res[1])
|
|
|
|
|
call assert_equal('> error list 3 of 3; 3 ' . common, res[2])
|
2019-04-14 13:54:33 -07:00
|
|
|
|
|
2021-01-01 02:47:35 -07:00
|
|
|
|
" Test for changing the quickfix lists
|
|
|
|
|
call assert_equal(3, g:Xgetlist({'nr' : 0}).nr)
|
|
|
|
|
exe '1' . a:cchar . 'hist'
|
|
|
|
|
call assert_equal(1, g:Xgetlist({'nr' : 0}).nr)
|
|
|
|
|
exe '3' . a:cchar . 'hist'
|
|
|
|
|
call assert_equal(3, g:Xgetlist({'nr' : 0}).nr)
|
|
|
|
|
call assert_fails('-2' . a:cchar . 'hist', 'E16:')
|
|
|
|
|
call assert_fails('4' . a:cchar . 'hist', 'E16:')
|
|
|
|
|
|
2019-04-14 13:54:33 -07:00
|
|
|
|
call g:Xsetlist([], 'f')
|
|
|
|
|
let l = split(execute(a:cchar . 'hist'), "\n")
|
|
|
|
|
call assert_equal('No entries', l[0])
|
2021-01-01 02:47:35 -07:00
|
|
|
|
if a:cchar == 'c'
|
|
|
|
|
call assert_fails('4chist', 'E16:')
|
|
|
|
|
else
|
|
|
|
|
call assert_fails('4lhist', 'E776:')
|
|
|
|
|
endif
|
2020-10-10 09:46:34 -07:00
|
|
|
|
|
|
|
|
|
" 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')
|
2017-01-17 00:36:00 -07:00
|
|
|
|
endfunc
|
|
|
|
|
|
|
|
|
|
func Test_history()
|
|
|
|
|
call HistoryTest('c')
|
|
|
|
|
call HistoryTest('l')
|
|
|
|
|
endfunc
|
2017-01-17 01:33:53 -07:00
|
|
|
|
|
|
|
|
|
func Test_duplicate_buf()
|
|
|
|
|
" make sure we can get the highest buffer number
|
|
|
|
|
edit DoesNotExist
|
|
|
|
|
edit DoesNotExist2
|
|
|
|
|
let last_buffer = bufnr("$")
|
|
|
|
|
|
|
|
|
|
" make sure only one buffer is created
|
|
|
|
|
call writefile(['this one', 'that one'], 'Xgrepthis')
|
|
|
|
|
vimgrep one Xgrepthis
|
|
|
|
|
vimgrep one Xgrepthis
|
|
|
|
|
call assert_equal(last_buffer + 1, bufnr("$"))
|
|
|
|
|
|
|
|
|
|
call delete('Xgrepthis')
|
|
|
|
|
endfunc
|
2017-02-27 07:52:03 -07:00
|
|
|
|
|
|
|
|
|
" Quickfix/Location list set/get properties tests
|
2017-07-16 08:32:32 -07:00
|
|
|
|
func Xproperty_tests(cchar)
|
2017-02-27 07:52:03 -07:00
|
|
|
|
call s:setup_commands(a:cchar)
|
|
|
|
|
|
|
|
|
|
" Error cases
|
|
|
|
|
call assert_fails('call g:Xgetlist(99)', 'E715:')
|
|
|
|
|
call assert_fails('call g:Xsetlist(99)', 'E714:')
|
|
|
|
|
call assert_fails('call g:Xsetlist([], "a", [])', 'E715:')
|
|
|
|
|
|
|
|
|
|
" Set and get the title
|
2017-12-18 12:26:49 -07:00
|
|
|
|
call g:Xsetlist([])
|
2017-02-27 07:52:03 -07:00
|
|
|
|
Xopen
|
|
|
|
|
wincmd p
|
|
|
|
|
call g:Xsetlist([{'filename':'foo', 'lnum':27}])
|
2018-07-28 07:22:19 -07:00
|
|
|
|
let s = g:Xsetlist([], 'a', {'title' : 'Sample'})
|
|
|
|
|
call assert_equal(0, s)
|
2017-02-27 07:52:03 -07:00
|
|
|
|
let d = g:Xgetlist({"title":1})
|
|
|
|
|
call assert_equal('Sample', d.title)
|
2019-09-03 20:24:32 -07:00
|
|
|
|
" Try setting title to a non-string value
|
|
|
|
|
call assert_equal(-1, g:Xsetlist([], 'a', {'title' : ['Test']}))
|
|
|
|
|
call assert_equal('Sample', g:Xgetlist({"title":1}).title)
|
2017-02-27 07:52:03 -07:00
|
|
|
|
|
|
|
|
|
Xopen
|
|
|
|
|
call assert_equal('Sample', w:quickfix_title)
|
|
|
|
|
Xclose
|
|
|
|
|
|
2017-03-14 07:07:48 -07:00
|
|
|
|
" Tests for action argument
|
|
|
|
|
silent! Xolder 999
|
|
|
|
|
let qfnr = g:Xgetlist({'all':1}).nr
|
|
|
|
|
call g:Xsetlist([], 'r', {'title' : 'N1'})
|
|
|
|
|
call assert_equal('N1', g:Xgetlist({'all':1}).title)
|
|
|
|
|
call g:Xsetlist([], ' ', {'title' : 'N2'})
|
|
|
|
|
call assert_equal(qfnr + 1, g:Xgetlist({'all':1}).nr)
|
2017-07-16 05:23:56 -07:00
|
|
|
|
|
|
|
|
|
let res = g:Xgetlist({'nr': 0})
|
|
|
|
|
call assert_equal(qfnr + 1, res.nr)
|
|
|
|
|
call assert_equal(['nr'], keys(res))
|
|
|
|
|
|
2017-03-14 07:07:48 -07:00
|
|
|
|
call g:Xsetlist([], ' ', {'title' : 'N3'})
|
|
|
|
|
call assert_equal('N2', g:Xgetlist({'nr':2, 'title':1}).title)
|
|
|
|
|
|
2017-12-17 18:56:01 -07:00
|
|
|
|
" Changing the title of an earlier quickfix list
|
2018-09-06 20:49:21 -07:00
|
|
|
|
call g:Xsetlist([], 'r', {'title' : 'NewTitle', 'nr' : 2})
|
2017-12-17 18:56:01 -07:00
|
|
|
|
call assert_equal('NewTitle', g:Xgetlist({'nr':2, 'title':1}).title)
|
|
|
|
|
|
|
|
|
|
" Changing the title of an invalid quickfix list
|
|
|
|
|
call assert_equal(-1, g:Xsetlist([], ' ',
|
|
|
|
|
\ {'title' : 'SomeTitle', 'nr' : 99}))
|
|
|
|
|
call assert_equal(-1, g:Xsetlist([], ' ',
|
|
|
|
|
\ {'title' : 'SomeTitle', 'nr' : 'abc'}))
|
|
|
|
|
|
|
|
|
|
if a:cchar == 'c'
|
|
|
|
|
copen
|
|
|
|
|
call assert_equal({'winid':win_getid()}, getqflist({'winid':1}))
|
|
|
|
|
cclose
|
|
|
|
|
endif
|
|
|
|
|
|
2017-02-27 07:52:03 -07:00
|
|
|
|
" Invalid arguments
|
|
|
|
|
call assert_fails('call g:Xgetlist([])', 'E715')
|
|
|
|
|
call assert_fails('call g:Xsetlist([], "a", [])', 'E715')
|
|
|
|
|
let s = g:Xsetlist([], 'a', {'abc':1})
|
|
|
|
|
call assert_equal(-1, s)
|
|
|
|
|
|
|
|
|
|
call assert_equal({}, g:Xgetlist({'abc':1}))
|
2019-04-19 09:54:56 -07:00
|
|
|
|
call assert_equal('', g:Xgetlist({'nr':99, 'title':1}).title)
|
|
|
|
|
call assert_equal('', g:Xgetlist({'nr':[], 'title':1}).title)
|
2017-02-27 07:52:03 -07:00
|
|
|
|
|
|
|
|
|
if a:cchar == 'l'
|
2017-12-17 18:56:01 -07:00
|
|
|
|
call assert_equal({}, getloclist(99, {'title': 1}))
|
2017-02-27 07:52:03 -07:00
|
|
|
|
endif
|
2017-12-19 06:39:09 -07:00
|
|
|
|
|
|
|
|
|
" Context related tests
|
2018-07-28 07:22:19 -07:00
|
|
|
|
let s = g:Xsetlist([], 'a', {'context':[1,2,3]})
|
|
|
|
|
call assert_equal(0, s)
|
2017-12-19 06:39:09 -07:00
|
|
|
|
call test_garbagecollect_now()
|
|
|
|
|
let d = g:Xgetlist({'context':1})
|
|
|
|
|
call assert_equal([1,2,3], d.context)
|
|
|
|
|
call g:Xsetlist([], 'a', {'context':{'color':'green'}})
|
|
|
|
|
let d = g:Xgetlist({'context':1})
|
|
|
|
|
call assert_equal({'color':'green'}, d.context)
|
|
|
|
|
call g:Xsetlist([], 'a', {'context':"Context info"})
|
|
|
|
|
let d = g:Xgetlist({'context':1})
|
|
|
|
|
call assert_equal("Context info", d.context)
|
|
|
|
|
call g:Xsetlist([], 'a', {'context':246})
|
|
|
|
|
let d = g:Xgetlist({'context':1})
|
|
|
|
|
call assert_equal(246, d.context)
|
2021-07-29 14:32:22 -07:00
|
|
|
|
" set other Vim data types as context
|
|
|
|
|
call g:Xsetlist([], 'a', {'context' : v:_null_blob})
|
2023-04-14 22:31:30 -07:00
|
|
|
|
if has('channel')
|
|
|
|
|
call g:Xsetlist([], 'a', {'context' : test_null_channel()})
|
|
|
|
|
endif
|
|
|
|
|
if has('job')
|
|
|
|
|
call g:Xsetlist([], 'a', {'context' : test_null_job()})
|
|
|
|
|
endif
|
|
|
|
|
" Nvim doesn't have null functions
|
|
|
|
|
" call g:Xsetlist([], 'a', {'context' : test_null_function()})
|
|
|
|
|
" Nvim doesn't have null partials
|
|
|
|
|
" call g:Xsetlist([], 'a', {'context' : test_null_partial()})
|
2021-07-29 14:32:22 -07:00
|
|
|
|
call g:Xsetlist([], 'a', {'context' : ''})
|
|
|
|
|
call test_garbagecollect_now()
|
2017-12-19 06:39:09 -07:00
|
|
|
|
if a:cchar == 'l'
|
|
|
|
|
" Test for copying context across two different location lists
|
|
|
|
|
new | only
|
|
|
|
|
let w1_id = win_getid()
|
|
|
|
|
let l = [1]
|
|
|
|
|
call setloclist(0, [], 'a', {'context':l})
|
|
|
|
|
new
|
|
|
|
|
let w2_id = win_getid()
|
|
|
|
|
call add(l, 2)
|
|
|
|
|
call assert_equal([1, 2], getloclist(w1_id, {'context':1}).context)
|
|
|
|
|
call assert_equal([1, 2], getloclist(w2_id, {'context':1}).context)
|
|
|
|
|
unlet! l
|
|
|
|
|
call assert_equal([1, 2], getloclist(w2_id, {'context':1}).context)
|
|
|
|
|
only
|
|
|
|
|
call setloclist(0, [], 'f')
|
2019-04-19 09:54:56 -07:00
|
|
|
|
call assert_equal('', getloclist(0, {'context':1}).context)
|
2017-12-19 06:39:09 -07:00
|
|
|
|
endif
|
2017-12-19 08:53:59 -07:00
|
|
|
|
|
|
|
|
|
" Test for changing the context of previous quickfix lists
|
|
|
|
|
call g:Xsetlist([], 'f')
|
|
|
|
|
Xexpr "One"
|
|
|
|
|
Xexpr "Two"
|
|
|
|
|
Xexpr "Three"
|
2018-09-06 20:49:21 -07:00
|
|
|
|
call g:Xsetlist([], 'r', {'context' : [1], 'nr' : 1})
|
|
|
|
|
call g:Xsetlist([], 'a', {'context' : [2], 'nr' : 2})
|
2017-12-19 08:53:59 -07:00
|
|
|
|
" Also, check for setting the context using quickfix list number zero.
|
2018-09-06 20:49:21 -07:00
|
|
|
|
call g:Xsetlist([], 'r', {'context' : [3], 'nr' : 0})
|
2017-12-19 08:53:59 -07:00
|
|
|
|
call test_garbagecollect_now()
|
|
|
|
|
let l = g:Xgetlist({'nr' : 1, 'context' : 1})
|
|
|
|
|
call assert_equal([1], l.context)
|
|
|
|
|
let l = g:Xgetlist({'nr' : 2, 'context' : 1})
|
|
|
|
|
call assert_equal([2], l.context)
|
|
|
|
|
let l = g:Xgetlist({'nr' : 3, 'context' : 1})
|
|
|
|
|
call assert_equal([3], l.context)
|
|
|
|
|
|
|
|
|
|
" Test for changing the context through reference and for garbage
|
|
|
|
|
" collection of quickfix context
|
|
|
|
|
let l = ["red"]
|
|
|
|
|
call g:Xsetlist([], ' ', {'context' : l})
|
|
|
|
|
call add(l, "blue")
|
|
|
|
|
let x = g:Xgetlist({'context' : 1})
|
|
|
|
|
call add(x.context, "green")
|
|
|
|
|
call assert_equal(["red", "blue", "green"], l)
|
|
|
|
|
call assert_equal(["red", "blue", "green"], x.context)
|
|
|
|
|
unlet l
|
|
|
|
|
call test_garbagecollect_now()
|
|
|
|
|
let m = g:Xgetlist({'context' : 1})
|
|
|
|
|
call assert_equal(["red", "blue", "green"], m.context)
|
2017-12-30 22:36:35 -07:00
|
|
|
|
|
|
|
|
|
" Test for setting/getting items
|
|
|
|
|
Xexpr ""
|
|
|
|
|
let qfprev = g:Xgetlist({'nr':0})
|
2018-07-28 07:22:19 -07:00
|
|
|
|
let s = g:Xsetlist([], ' ', {'title':'Green',
|
2017-12-30 22:36:35 -07:00
|
|
|
|
\ 'items' : [{'filename':'F1', 'lnum':10}]})
|
2018-07-28 07:22:19 -07:00
|
|
|
|
call assert_equal(0, s)
|
2017-12-30 22:36:35 -07:00
|
|
|
|
let qfcur = g:Xgetlist({'nr':0})
|
|
|
|
|
call assert_true(qfcur.nr == qfprev.nr + 1)
|
|
|
|
|
let l = g:Xgetlist({'items':1})
|
|
|
|
|
call assert_equal('F1', bufname(l.items[0].bufnr))
|
|
|
|
|
call assert_equal(10, l.items[0].lnum)
|
|
|
|
|
call g:Xsetlist([], 'a', {'items' : [{'filename':'F2', 'lnum':20},
|
|
|
|
|
\ {'filename':'F2', 'lnum':30}]})
|
|
|
|
|
let l = g:Xgetlist({'items':1})
|
|
|
|
|
call assert_equal('F2', bufname(l.items[2].bufnr))
|
|
|
|
|
call assert_equal(30, l.items[2].lnum)
|
|
|
|
|
call g:Xsetlist([], 'r', {'items' : [{'filename':'F3', 'lnum':40}]})
|
|
|
|
|
let l = g:Xgetlist({'items':1})
|
|
|
|
|
call assert_equal('F3', bufname(l.items[0].bufnr))
|
|
|
|
|
call assert_equal(40, l.items[0].lnum)
|
|
|
|
|
call g:Xsetlist([], 'r', {'items' : []})
|
|
|
|
|
let l = g:Xgetlist({'items':1})
|
|
|
|
|
call assert_equal(0, len(l.items))
|
|
|
|
|
|
2019-04-14 13:54:33 -07:00
|
|
|
|
call g:Xsetlist([], 'r', {'title' : 'TestTitle'})
|
|
|
|
|
call g:Xsetlist([], 'r', {'items' : [{'filename' : 'F1', 'lnum' : 10, 'text' : 'L10'}]})
|
|
|
|
|
call g:Xsetlist([], 'r', {'items' : [{'filename' : 'F1', 'lnum' : 10, 'text' : 'L10'}]})
|
|
|
|
|
call assert_equal('TestTitle', g:Xgetlist({'title' : 1}).title)
|
|
|
|
|
|
2019-10-13 16:49:17 -07:00
|
|
|
|
" Test for getting id of window associated with a location list window
|
|
|
|
|
if a:cchar == 'l'
|
|
|
|
|
only
|
|
|
|
|
call assert_equal(0, g:Xgetlist({'all' : 1}).filewinid)
|
|
|
|
|
let wid = win_getid()
|
|
|
|
|
Xopen
|
|
|
|
|
call assert_equal(wid, g:Xgetlist({'filewinid' : 1}).filewinid)
|
|
|
|
|
wincmd w
|
|
|
|
|
call assert_equal(0, g:Xgetlist({'filewinid' : 1}).filewinid)
|
|
|
|
|
only
|
|
|
|
|
endif
|
|
|
|
|
|
2018-09-06 18:54:30 -07:00
|
|
|
|
" The following used to crash Vim with address sanitizer
|
|
|
|
|
call g:Xsetlist([], 'f')
|
|
|
|
|
call g:Xsetlist([], 'a', {'items' : [{'filename':'F1', 'lnum':10}]})
|
|
|
|
|
call assert_equal(10, g:Xgetlist({'items':1}).items[0].lnum)
|
|
|
|
|
|
2019-09-03 20:24:32 -07:00
|
|
|
|
" Try setting the items using a string
|
|
|
|
|
call assert_equal(-1, g:Xsetlist([], ' ', {'items' : 'Test'}))
|
|
|
|
|
|
2017-12-30 22:36:35 -07:00
|
|
|
|
" Save and restore the quickfix stack
|
|
|
|
|
call g:Xsetlist([], 'f')
|
|
|
|
|
call assert_equal(0, g:Xgetlist({'nr':'$'}).nr)
|
|
|
|
|
Xexpr "File1:10:Line1"
|
|
|
|
|
Xexpr "File2:20:Line2"
|
|
|
|
|
Xexpr "File3:30:Line3"
|
|
|
|
|
let last_qf = g:Xgetlist({'nr':'$'}).nr
|
|
|
|
|
call assert_equal(3, last_qf)
|
|
|
|
|
let qstack = []
|
|
|
|
|
for i in range(1, last_qf)
|
|
|
|
|
let qstack = add(qstack, g:Xgetlist({'nr':i, 'all':1}))
|
|
|
|
|
endfor
|
|
|
|
|
call g:Xsetlist([], 'f')
|
|
|
|
|
for i in range(len(qstack))
|
|
|
|
|
call g:Xsetlist([], ' ', qstack[i])
|
|
|
|
|
endfor
|
|
|
|
|
call assert_equal(3, g:Xgetlist({'nr':'$'}).nr)
|
|
|
|
|
call assert_equal(10, g:Xgetlist({'nr':1, 'items':1}).items[0].lnum)
|
|
|
|
|
call assert_equal(20, g:Xgetlist({'nr':2, 'items':1}).items[0].lnum)
|
|
|
|
|
call assert_equal(30, g:Xgetlist({'nr':3, 'items':1}).items[0].lnum)
|
|
|
|
|
call g:Xsetlist([], 'f')
|
|
|
|
|
|
|
|
|
|
" Swap two quickfix lists
|
|
|
|
|
Xexpr "File1:10:Line10"
|
|
|
|
|
Xexpr "File2:20:Line20"
|
|
|
|
|
Xexpr "File3:30:Line30"
|
|
|
|
|
call g:Xsetlist([], 'r', {'nr':1,'title':'Colors','context':['Colors']})
|
|
|
|
|
call g:Xsetlist([], 'r', {'nr':2,'title':'Fruits','context':['Fruits']})
|
|
|
|
|
let l1=g:Xgetlist({'nr':1,'all':1})
|
|
|
|
|
let l2=g:Xgetlist({'nr':2,'all':1})
|
2018-09-08 03:13:23 -07:00
|
|
|
|
let save_id = l1.id
|
|
|
|
|
let l1.id=l2.id
|
|
|
|
|
let l2.id=save_id
|
2017-12-30 22:36:35 -07:00
|
|
|
|
call g:Xsetlist([], 'r', l1)
|
|
|
|
|
call g:Xsetlist([], 'r', l2)
|
|
|
|
|
let newl1=g:Xgetlist({'nr':1,'all':1})
|
|
|
|
|
let newl2=g:Xgetlist({'nr':2,'all':1})
|
2019-04-14 13:54:33 -07:00
|
|
|
|
call assert_equal('Fruits', newl1.title)
|
2017-12-30 22:36:35 -07:00
|
|
|
|
call assert_equal(['Fruits'], newl1.context)
|
|
|
|
|
call assert_equal('Line20', newl1.items[0].text)
|
2019-04-14 13:54:33 -07:00
|
|
|
|
call assert_equal('Colors', newl2.title)
|
2017-12-30 22:36:35 -07:00
|
|
|
|
call assert_equal(['Colors'], newl2.context)
|
|
|
|
|
call assert_equal('Line10', newl2.items[0].text)
|
|
|
|
|
call g:Xsetlist([], 'f')
|
2020-10-10 21:05:53 -07:00
|
|
|
|
|
|
|
|
|
" Cannot specify both a non-empty list argument and a dict argument
|
|
|
|
|
call assert_fails("call g:Xsetlist([{}], ' ', {})", 'E475:')
|
2017-12-17 18:56:01 -07:00
|
|
|
|
endfunc
|
2017-02-27 07:52:03 -07:00
|
|
|
|
|
2017-07-16 08:32:32 -07:00
|
|
|
|
func Test_qf_property()
|
2017-02-27 07:52:03 -07:00
|
|
|
|
call Xproperty_tests('c')
|
|
|
|
|
call Xproperty_tests('l')
|
2017-12-17 18:56:01 -07:00
|
|
|
|
endfunc
|
2017-03-07 15:31:15 -07:00
|
|
|
|
|
2020-10-10 09:46:34 -07:00
|
|
|
|
" 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
|
|
|
|
|
|
2017-03-07 15:31:15 -07:00
|
|
|
|
" Tests for the QuickFixCmdPre/QuickFixCmdPost autocommands
|
2017-07-16 08:32:32 -07:00
|
|
|
|
func QfAutoCmdHandler(loc, cmd)
|
2017-03-07 15:31:15 -07:00
|
|
|
|
call add(g:acmds, a:loc . a:cmd)
|
2017-07-16 08:32:32 -07:00
|
|
|
|
endfunc
|
2017-03-07 15:31:15 -07:00
|
|
|
|
|
2017-07-16 08:32:32 -07:00
|
|
|
|
func Test_Autocmd()
|
2017-03-07 15:31:15 -07:00
|
|
|
|
autocmd QuickFixCmdPre * call QfAutoCmdHandler('pre', expand('<amatch>'))
|
|
|
|
|
autocmd QuickFixCmdPost * call QfAutoCmdHandler('post', expand('<amatch>'))
|
|
|
|
|
|
|
|
|
|
let g:acmds = []
|
|
|
|
|
cexpr "F1:10:Line 10"
|
|
|
|
|
caddexpr "F1:20:Line 20"
|
|
|
|
|
cgetexpr "F1:30:Line 30"
|
2019-04-19 04:38:14 -07:00
|
|
|
|
cexpr ""
|
|
|
|
|
caddexpr ""
|
|
|
|
|
cgetexpr ""
|
|
|
|
|
silent! cexpr non_existing_func()
|
|
|
|
|
silent! caddexpr non_existing_func()
|
|
|
|
|
silent! cgetexpr non_existing_func()
|
2022-10-12 23:31:10 -07:00
|
|
|
|
let l =<< trim END
|
|
|
|
|
precexpr
|
|
|
|
|
postcexpr
|
|
|
|
|
precaddexpr
|
|
|
|
|
postcaddexpr
|
|
|
|
|
precgetexpr
|
|
|
|
|
postcgetexpr
|
|
|
|
|
precexpr
|
|
|
|
|
postcexpr
|
|
|
|
|
precaddexpr
|
|
|
|
|
postcaddexpr
|
|
|
|
|
precgetexpr
|
|
|
|
|
postcgetexpr
|
|
|
|
|
precexpr
|
|
|
|
|
precaddexpr
|
|
|
|
|
precgetexpr
|
|
|
|
|
END
|
2019-04-19 04:38:14 -07:00
|
|
|
|
call assert_equal(l, g:acmds)
|
|
|
|
|
|
|
|
|
|
let g:acmds = []
|
2017-03-07 15:31:15 -07:00
|
|
|
|
enew! | call append(0, "F2:10:Line 10")
|
|
|
|
|
cbuffer!
|
|
|
|
|
enew! | call append(0, "F2:20:Line 20")
|
|
|
|
|
cgetbuffer
|
|
|
|
|
enew! | call append(0, "F2:30:Line 30")
|
|
|
|
|
caddbuffer
|
|
|
|
|
|
2019-04-19 04:38:14 -07:00
|
|
|
|
new
|
|
|
|
|
let bnum = bufnr('%')
|
|
|
|
|
bunload
|
|
|
|
|
exe 'silent! cbuffer! ' . bnum
|
|
|
|
|
exe 'silent! cgetbuffer ' . bnum
|
|
|
|
|
exe 'silent! caddbuffer ' . bnum
|
|
|
|
|
enew!
|
2022-10-12 23:31:10 -07:00
|
|
|
|
let l =<< trim END
|
|
|
|
|
precbuffer
|
|
|
|
|
postcbuffer
|
|
|
|
|
precgetbuffer
|
|
|
|
|
postcgetbuffer
|
|
|
|
|
precaddbuffer
|
|
|
|
|
postcaddbuffer
|
|
|
|
|
precbuffer
|
|
|
|
|
precgetbuffer
|
|
|
|
|
precaddbuffer
|
|
|
|
|
END
|
2019-04-19 04:38:14 -07:00
|
|
|
|
call assert_equal(l, g:acmds)
|
|
|
|
|
|
|
|
|
|
call writefile(['Xtest:1:Line1'], 'Xtest')
|
|
|
|
|
call writefile([], 'Xempty')
|
|
|
|
|
let g:acmds = []
|
|
|
|
|
cfile Xtest
|
|
|
|
|
caddfile Xtest
|
|
|
|
|
cgetfile Xtest
|
|
|
|
|
cfile Xempty
|
|
|
|
|
caddfile Xempty
|
|
|
|
|
cgetfile Xempty
|
|
|
|
|
silent! cfile do_not_exist
|
|
|
|
|
silent! caddfile do_not_exist
|
|
|
|
|
silent! cgetfile do_not_exist
|
2022-10-12 23:31:10 -07:00
|
|
|
|
let l =<< trim END
|
|
|
|
|
precfile
|
|
|
|
|
postcfile
|
|
|
|
|
precaddfile
|
|
|
|
|
postcaddfile
|
|
|
|
|
precgetfile
|
|
|
|
|
postcgetfile
|
|
|
|
|
precfile
|
|
|
|
|
postcfile
|
|
|
|
|
precaddfile
|
|
|
|
|
postcaddfile
|
|
|
|
|
precgetfile
|
|
|
|
|
postcgetfile
|
|
|
|
|
precfile
|
|
|
|
|
postcfile
|
|
|
|
|
precaddfile
|
|
|
|
|
postcaddfile
|
|
|
|
|
precgetfile
|
|
|
|
|
postcgetfile
|
|
|
|
|
END
|
2019-04-19 04:38:14 -07:00
|
|
|
|
call assert_equal(l, g:acmds)
|
|
|
|
|
|
|
|
|
|
let g:acmds = []
|
|
|
|
|
helpgrep quickfix
|
|
|
|
|
silent! helpgrep non_existing_help_topic
|
|
|
|
|
vimgrep test Xtest
|
|
|
|
|
vimgrepadd test Xtest
|
|
|
|
|
silent! vimgrep non_existing_test Xtest
|
|
|
|
|
silent! vimgrepadd non_existing_test Xtest
|
|
|
|
|
set makeprg=
|
|
|
|
|
silent! make
|
|
|
|
|
set makeprg&
|
2022-10-12 23:31:10 -07:00
|
|
|
|
let l =<< trim END
|
|
|
|
|
prehelpgrep
|
|
|
|
|
posthelpgrep
|
|
|
|
|
prehelpgrep
|
|
|
|
|
posthelpgrep
|
|
|
|
|
previmgrep
|
|
|
|
|
postvimgrep
|
|
|
|
|
previmgrepadd
|
|
|
|
|
postvimgrepadd
|
|
|
|
|
previmgrep
|
|
|
|
|
postvimgrep
|
|
|
|
|
previmgrepadd
|
|
|
|
|
postvimgrepadd
|
|
|
|
|
premake
|
|
|
|
|
postmake
|
|
|
|
|
END
|
2017-03-07 15:31:15 -07:00
|
|
|
|
call assert_equal(l, g:acmds)
|
2019-04-19 04:38:14 -07:00
|
|
|
|
|
|
|
|
|
if has('unix')
|
|
|
|
|
" Run this test only on Unix-like systems. The grepprg may not be set on
|
|
|
|
|
" non-Unix systems.
|
|
|
|
|
" The following lines are used for the grep test. Don't remove.
|
|
|
|
|
" Grep_Autocmd_Text: Match 1
|
|
|
|
|
" GrepAdd_Autocmd_Text: Match 2
|
|
|
|
|
let g:acmds = []
|
|
|
|
|
silent grep Grep_Autocmd_Text test_quickfix.vim
|
|
|
|
|
silent grepadd GrepAdd_Autocmd_Text test_quickfix.vim
|
|
|
|
|
silent grep abc123def Xtest
|
|
|
|
|
silent grepadd abc123def Xtest
|
2021-01-01 11:10:08 -07:00
|
|
|
|
set grepprg=internal
|
|
|
|
|
silent grep Grep_Autocmd_Text test_quickfix.vim
|
|
|
|
|
silent grepadd GrepAdd_Autocmd_Text test_quickfix.vim
|
|
|
|
|
silent lgrep Grep_Autocmd_Text test_quickfix.vim
|
|
|
|
|
silent lgrepadd GrepAdd_Autocmd_Text test_quickfix.vim
|
|
|
|
|
set grepprg&vim
|
2022-10-12 23:31:10 -07:00
|
|
|
|
let l =<< trim END
|
|
|
|
|
pregrep
|
|
|
|
|
postgrep
|
|
|
|
|
pregrepadd
|
|
|
|
|
postgrepadd
|
|
|
|
|
pregrep
|
|
|
|
|
postgrep
|
|
|
|
|
pregrepadd
|
|
|
|
|
postgrepadd
|
|
|
|
|
pregrep
|
|
|
|
|
postgrep
|
|
|
|
|
pregrepadd
|
|
|
|
|
postgrepadd
|
|
|
|
|
prelgrep
|
|
|
|
|
postlgrep
|
|
|
|
|
prelgrepadd
|
|
|
|
|
postlgrepadd
|
|
|
|
|
END
|
2019-04-19 04:38:14 -07:00
|
|
|
|
call assert_equal(l, g:acmds)
|
|
|
|
|
endif
|
|
|
|
|
|
|
|
|
|
call delete('Xtest')
|
|
|
|
|
call delete('Xempty')
|
2019-04-19 04:13:24 -07:00
|
|
|
|
au! QuickFixCmdPre
|
|
|
|
|
au! QuickFixCmdPost
|
2017-07-16 08:32:32 -07:00
|
|
|
|
endfunc
|
2017-03-11 05:56:23 -07:00
|
|
|
|
|
2017-07-16 08:32:32 -07:00
|
|
|
|
func Test_Autocmd_Exception()
|
2017-03-11 05:56:23 -07:00
|
|
|
|
set efm=%m
|
|
|
|
|
lgetexpr '?'
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
call DoesNotExit()
|
|
|
|
|
catch
|
|
|
|
|
lgetexpr '1'
|
|
|
|
|
finally
|
|
|
|
|
lgetexpr '1'
|
|
|
|
|
endtry
|
|
|
|
|
|
|
|
|
|
call assert_equal('1', getloclist(0)[0].text)
|
|
|
|
|
|
|
|
|
|
set efm&vim
|
2017-07-16 08:32:32 -07:00
|
|
|
|
endfunc
|
2017-07-16 08:28:14 -07:00
|
|
|
|
|
2017-07-16 08:32:32 -07:00
|
|
|
|
func Test_caddbuffer_wrong()
|
|
|
|
|
" This used to cause a memory access in freed memory.
|
2017-07-16 08:28:14 -07:00
|
|
|
|
let save_efm = &efm
|
|
|
|
|
set efm=%EEEE%m,%WWWW,%+CCCC%>%#,%GGGG%.#
|
|
|
|
|
cgetexpr ['WWWW', 'EEEE', 'CCCC']
|
|
|
|
|
let &efm = save_efm
|
2017-07-16 08:32:32 -07:00
|
|
|
|
caddbuffer
|
2017-07-16 08:28:14 -07:00
|
|
|
|
bwipe!
|
|
|
|
|
endfunc
|
2017-07-16 08:32:32 -07:00
|
|
|
|
|
|
|
|
|
func Test_caddexpr_wrong()
|
|
|
|
|
" This used to cause a memory access in freed memory.
|
|
|
|
|
cbuffer
|
|
|
|
|
cbuffer
|
|
|
|
|
copen
|
|
|
|
|
let save_efm = &efm
|
|
|
|
|
set efm=%
|
|
|
|
|
call assert_fails('caddexpr ""', 'E376:')
|
|
|
|
|
let &efm = save_efm
|
|
|
|
|
endfunc
|
2017-07-16 08:39:53 -07:00
|
|
|
|
|
|
|
|
|
func Test_dirstack_cleanup()
|
|
|
|
|
" This used to cause a memory access in freed memory.
|
|
|
|
|
let save_efm = &efm
|
|
|
|
|
lexpr '0'
|
|
|
|
|
lopen
|
|
|
|
|
fun X(c)
|
|
|
|
|
let save_efm=&efm
|
|
|
|
|
set efm=%D%f
|
|
|
|
|
if a:c == 'c'
|
|
|
|
|
caddexpr '::'
|
|
|
|
|
else
|
|
|
|
|
laddexpr ':0:0'
|
|
|
|
|
endif
|
|
|
|
|
let &efm=save_efm
|
|
|
|
|
endfun
|
|
|
|
|
call X('c')
|
|
|
|
|
call X('l')
|
|
|
|
|
call setqflist([], 'r')
|
|
|
|
|
caddbuffer
|
|
|
|
|
let &efm = save_efm
|
|
|
|
|
endfunc
|
2017-12-17 18:51:51 -07:00
|
|
|
|
|
|
|
|
|
" Tests for jumping to entries from the location list window and quickfix
|
|
|
|
|
" window
|
|
|
|
|
func Test_cwindow_jump()
|
|
|
|
|
set efm=%f%%%l%%%m
|
|
|
|
|
lgetexpr ["F1%10%Line 10", "F2%20%Line 20", "F3%30%Line 30"]
|
|
|
|
|
lopen | only
|
|
|
|
|
lfirst
|
|
|
|
|
call assert_true(winnr('$') == 2)
|
|
|
|
|
call assert_true(winnr() == 1)
|
|
|
|
|
" Location list for the new window should be set
|
|
|
|
|
call assert_true(getloclist(0)[2].text == 'Line 30')
|
|
|
|
|
|
|
|
|
|
" Open a scratch buffer
|
|
|
|
|
" Open a new window and create a location list
|
|
|
|
|
" Open the location list window and close the other window
|
|
|
|
|
" Jump to an entry.
|
2021-12-19 00:46:28 -07:00
|
|
|
|
" Should create a new window and jump to the entry. The scratch buffer
|
2017-12-17 18:51:51 -07:00
|
|
|
|
" should not be used.
|
|
|
|
|
enew | only
|
|
|
|
|
set buftype=nofile
|
|
|
|
|
below new
|
|
|
|
|
lgetexpr ["F1%10%Line 10", "F2%20%Line 20", "F3%30%Line 30"]
|
|
|
|
|
lopen
|
|
|
|
|
2wincmd c
|
|
|
|
|
lnext
|
|
|
|
|
call assert_true(winnr('$') == 3)
|
|
|
|
|
call assert_true(winnr() == 2)
|
|
|
|
|
|
|
|
|
|
" Open two windows with two different location lists
|
|
|
|
|
" Open the location list window and close the previous window
|
|
|
|
|
" Jump to an entry in the location list window
|
|
|
|
|
" Should open the file in the first window and not set the location list.
|
|
|
|
|
enew | only
|
|
|
|
|
lgetexpr ["F1%5%Line 5"]
|
|
|
|
|
below new
|
|
|
|
|
lgetexpr ["F1%10%Line 10", "F2%20%Line 20", "F3%30%Line 30"]
|
|
|
|
|
lopen
|
|
|
|
|
2wincmd c
|
|
|
|
|
lnext
|
|
|
|
|
call assert_true(winnr() == 1)
|
|
|
|
|
call assert_true(getloclist(0)[0].text == 'Line 5')
|
|
|
|
|
|
|
|
|
|
enew | only
|
|
|
|
|
cgetexpr ["F1%10%Line 10", "F2%20%Line 20", "F3%30%Line 30"]
|
|
|
|
|
copen
|
|
|
|
|
cnext
|
|
|
|
|
call assert_true(winnr('$') == 2)
|
|
|
|
|
call assert_true(winnr() == 1)
|
|
|
|
|
|
2022-02-14 01:17:11 -07:00
|
|
|
|
" open the quickfix buffer in two windows and jump to an entry. Should open
|
|
|
|
|
" the file in the first quickfix window.
|
|
|
|
|
enew | only
|
|
|
|
|
copen
|
|
|
|
|
let bnum = bufnr('')
|
|
|
|
|
exe 'sbuffer ' . bnum
|
|
|
|
|
wincmd b
|
|
|
|
|
cfirst
|
|
|
|
|
call assert_equal(2, winnr())
|
2022-07-16 18:10:25 -07:00
|
|
|
|
call assert_equal('F1', @%)
|
2022-02-14 01:17:11 -07:00
|
|
|
|
enew | only
|
|
|
|
|
exe 'sb' bnum
|
|
|
|
|
exe 'botright sb' bnum
|
|
|
|
|
wincmd t
|
|
|
|
|
clast
|
|
|
|
|
call assert_equal(2, winnr())
|
|
|
|
|
call assert_equal('quickfix', getwinvar(1, '&buftype'))
|
|
|
|
|
call assert_equal('quickfix', getwinvar(3, '&buftype'))
|
|
|
|
|
|
2022-02-14 03:56:30 -07:00
|
|
|
|
" Jumping to a file from the location list window should find a usable
|
2021-01-01 11:10:08 -07:00
|
|
|
|
" window by wrapping around the window list.
|
|
|
|
|
enew | only
|
|
|
|
|
call setloclist(0, [], 'f')
|
|
|
|
|
new | new
|
|
|
|
|
lgetexpr ["F1%10%Line 10", "F2%20%Line 20", "F3%30%Line 30"]
|
|
|
|
|
lopen
|
|
|
|
|
1close
|
|
|
|
|
call assert_equal(0, getloclist(3, {'id' : 0}).id)
|
|
|
|
|
lnext
|
|
|
|
|
call assert_equal(3, winnr())
|
|
|
|
|
call assert_equal(getloclist(1, {'id' : 0}).id, getloclist(3, {'id' : 0}).id)
|
|
|
|
|
|
2017-12-17 18:51:51 -07:00
|
|
|
|
enew | only
|
|
|
|
|
set efm&vim
|
|
|
|
|
endfunc
|
2017-12-17 18:56:01 -07:00
|
|
|
|
|
2021-06-13 09:26:34 -07:00
|
|
|
|
func Test_cwindow_highlight()
|
|
|
|
|
CheckScreendump
|
|
|
|
|
|
|
|
|
|
let lines =<< trim END
|
2022-10-12 23:31:10 -07:00
|
|
|
|
call setline(1, ['some', 'text', 'with', 'matches'])
|
|
|
|
|
write XCwindow
|
|
|
|
|
vimgrep e XCwindow
|
|
|
|
|
redraw
|
|
|
|
|
cwindow 4
|
2021-06-13 09:26:34 -07:00
|
|
|
|
END
|
|
|
|
|
call writefile(lines, 'XtestCwindow')
|
|
|
|
|
let buf = RunVimInTerminal('-S XtestCwindow', #{rows: 12})
|
|
|
|
|
call VerifyScreenDump(buf, 'Test_quickfix_cwindow_1', {})
|
2022-12-11 17:53:07 -07:00
|
|
|
|
|
2021-06-13 09:26:34 -07:00
|
|
|
|
call term_sendkeys(buf, ":cnext\<CR>")
|
|
|
|
|
call VerifyScreenDump(buf, 'Test_quickfix_cwindow_2', {})
|
|
|
|
|
|
|
|
|
|
" clean up
|
|
|
|
|
call StopVimInTerminal(buf)
|
|
|
|
|
call delete('XtestCwindow')
|
|
|
|
|
call delete('XCwindow')
|
|
|
|
|
endfunc
|
|
|
|
|
|
2017-12-17 18:56:01 -07:00
|
|
|
|
func XvimgrepTests(cchar)
|
|
|
|
|
call s:setup_commands(a:cchar)
|
|
|
|
|
|
2022-10-12 23:31:10 -07:00
|
|
|
|
let lines =<< trim END
|
|
|
|
|
Editor:VIM vim
|
|
|
|
|
Editor:Emacs EmAcS
|
|
|
|
|
Editor:Notepad NOTEPAD
|
|
|
|
|
END
|
|
|
|
|
call writefile(lines, 'Xtestfile1')
|
|
|
|
|
call writefile(['Linux', 'macOS', 'MS-Windows'], 'Xtestfile2')
|
2017-12-17 18:56:01 -07:00
|
|
|
|
|
|
|
|
|
" Error cases
|
|
|
|
|
call assert_fails('Xvimgrep /abc *', 'E682:')
|
|
|
|
|
|
|
|
|
|
let @/=''
|
|
|
|
|
call assert_fails('Xvimgrep // *', 'E35:')
|
|
|
|
|
|
|
|
|
|
call assert_fails('Xvimgrep abc', 'E683:')
|
|
|
|
|
call assert_fails('Xvimgrep a1b2c3 Xtestfile1', 'E480:')
|
|
|
|
|
call assert_fails('Xvimgrep pat Xa1b2c3', 'E480:')
|
|
|
|
|
|
|
|
|
|
Xexpr ""
|
|
|
|
|
Xvimgrepadd Notepad Xtestfile1
|
2022-10-12 23:31:10 -07:00
|
|
|
|
Xvimgrepadd macOS Xtestfile2
|
2017-12-17 18:56:01 -07:00
|
|
|
|
let l = g:Xgetlist()
|
|
|
|
|
call assert_equal(2, len(l))
|
|
|
|
|
call assert_equal('Editor:Notepad NOTEPAD', l[0].text)
|
|
|
|
|
|
2021-05-20 15:05:39 -07:00
|
|
|
|
10Xvimgrep #\cvim#g Xtestfile?
|
2017-12-17 18:56:01 -07:00
|
|
|
|
let l = g:Xgetlist()
|
|
|
|
|
call assert_equal(2, len(l))
|
|
|
|
|
call assert_equal(8, l[0].col)
|
2021-07-31 10:10:44 -07:00
|
|
|
|
call assert_equal(11, l[0].end_col)
|
2017-12-17 18:56:01 -07:00
|
|
|
|
call assert_equal(12, l[1].col)
|
2021-07-31 10:10:44 -07:00
|
|
|
|
call assert_equal(15, l[1].end_col)
|
2017-12-17 18:56:01 -07:00
|
|
|
|
|
|
|
|
|
1Xvimgrep ?Editor? Xtestfile*
|
|
|
|
|
let l = g:Xgetlist()
|
|
|
|
|
call assert_equal(1, len(l))
|
|
|
|
|
call assert_equal('Editor:VIM vim', l[0].text)
|
|
|
|
|
|
|
|
|
|
edit +3 Xtestfile2
|
|
|
|
|
Xvimgrep +\cemacs+j Xtestfile1
|
|
|
|
|
let l = g:Xgetlist()
|
2022-07-16 18:10:25 -07:00
|
|
|
|
call assert_equal('Xtestfile2', @%)
|
2017-12-17 18:56:01 -07:00
|
|
|
|
call assert_equal('Editor:Emacs EmAcS', l[0].text)
|
|
|
|
|
|
2019-09-23 22:28:04 -07:00
|
|
|
|
" Test for unloading a buffer after vimgrep searched the buffer
|
|
|
|
|
%bwipe
|
|
|
|
|
Xvimgrep /Editor/j Xtestfile*
|
|
|
|
|
call assert_equal(0, getbufinfo('Xtestfile1')[0].loaded)
|
|
|
|
|
call assert_equal([], getbufinfo('Xtestfile2'))
|
|
|
|
|
|
2022-10-12 19:13:17 -07:00
|
|
|
|
" Test for opening the dummy buffer used by vimgrep in a window. The new
|
|
|
|
|
" window should be closed
|
|
|
|
|
%bw!
|
|
|
|
|
augroup QF_Test
|
|
|
|
|
au!
|
|
|
|
|
autocmd BufReadPre * exe "sb " .. expand("<abuf>")
|
|
|
|
|
augroup END
|
|
|
|
|
call assert_fails("Xvimgrep /sublime/ Xtestfile1", 'E480:')
|
|
|
|
|
call assert_equal(1, winnr('$'))
|
|
|
|
|
augroup QF_Test
|
|
|
|
|
au!
|
|
|
|
|
augroup END
|
|
|
|
|
|
2017-12-17 18:56:01 -07:00
|
|
|
|
call delete('Xtestfile1')
|
|
|
|
|
call delete('Xtestfile2')
|
|
|
|
|
endfunc
|
|
|
|
|
|
|
|
|
|
" Tests for the :vimgrep command
|
|
|
|
|
func Test_vimgrep()
|
|
|
|
|
call XvimgrepTests('c')
|
|
|
|
|
call XvimgrepTests('l')
|
|
|
|
|
endfunc
|
2017-12-18 12:36:13 -07:00
|
|
|
|
|
2021-01-31 08:10:22 -07:00
|
|
|
|
func Test_vimgrep_wildcards_expanded_once()
|
|
|
|
|
new X[id-01] file.txt
|
|
|
|
|
call setline(1, 'some text to search for')
|
|
|
|
|
vimgrep text %
|
|
|
|
|
bwipe!
|
|
|
|
|
endfunc
|
|
|
|
|
|
2020-09-12 22:33:53 -07:00
|
|
|
|
" Test for incsearch highlighting of the :vimgrep pattern
|
|
|
|
|
" This test used to cause "E315: ml_get: invalid lnum" errors.
|
|
|
|
|
func Test_vimgrep_incsearch()
|
2021-03-26 20:06:39 -07:00
|
|
|
|
CheckFunction test_override
|
2020-09-12 22:33:53 -07:00
|
|
|
|
enew
|
|
|
|
|
set incsearch
|
|
|
|
|
call test_override("char_avail", 1)
|
|
|
|
|
|
|
|
|
|
call feedkeys(":2vimgrep assert test_quickfix.vim test_cdo.vim\<CR>", "ntx")
|
|
|
|
|
let l = getqflist()
|
|
|
|
|
call assert_equal(2, len(l))
|
|
|
|
|
|
|
|
|
|
call test_override("ALL", 0)
|
|
|
|
|
set noincsearch
|
|
|
|
|
endfunc
|
2020-10-17 06:03:50 -07:00
|
|
|
|
|
2022-07-08 02:43:05 -07:00
|
|
|
|
" Test vimgrep with the last search pattern not set
|
|
|
|
|
func Test_vimgrep_with_no_last_search_pat()
|
|
|
|
|
let lines =<< trim [SCRIPT]
|
|
|
|
|
call assert_fails('vimgrep // *', 'E35:')
|
|
|
|
|
call writefile(v:errors, 'Xresult')
|
|
|
|
|
qall!
|
|
|
|
|
[SCRIPT]
|
|
|
|
|
call writefile(lines, 'Xscript')
|
|
|
|
|
if RunVim([], [], '--clean -S Xscript')
|
|
|
|
|
call assert_equal([], readfile('Xresult'))
|
|
|
|
|
endif
|
|
|
|
|
call delete('Xscript')
|
|
|
|
|
call delete('Xresult')
|
|
|
|
|
endfunc
|
|
|
|
|
|
2020-10-17 08:05:33 -07:00
|
|
|
|
" Test vimgrep without swap file
|
|
|
|
|
func Test_vimgrep_without_swap_file()
|
|
|
|
|
let lines =<< trim [SCRIPT]
|
|
|
|
|
vimgrep grep test_c*
|
|
|
|
|
call writefile(['done'], 'Xresult')
|
|
|
|
|
qall!
|
|
|
|
|
[SCRIPT]
|
|
|
|
|
call writefile(lines, 'Xscript')
|
|
|
|
|
if RunVim([], [], '--clean -n -S Xscript Xscript')
|
|
|
|
|
call assert_equal(['done'], readfile('Xresult'))
|
|
|
|
|
endif
|
|
|
|
|
call delete('Xscript')
|
|
|
|
|
call delete('Xresult')
|
|
|
|
|
endfunc
|
|
|
|
|
|
2020-10-17 06:03:50 -07:00
|
|
|
|
func Test_vimgrep_existing_swapfile()
|
|
|
|
|
call writefile(['match apple with apple'], 'Xapple')
|
|
|
|
|
call writefile(['swapfile'], '.Xapple.swp')
|
|
|
|
|
let g:foundSwap = 0
|
|
|
|
|
let g:ignoreSwapExists = 1
|
|
|
|
|
augroup grep
|
|
|
|
|
au SwapExists * let foundSwap = 1 | let v:swapchoice = 'e'
|
|
|
|
|
augroup END
|
|
|
|
|
vimgrep apple Xapple
|
|
|
|
|
call assert_equal(1, g:foundSwap)
|
|
|
|
|
call assert_match('.Xapple.swo', swapname(''))
|
|
|
|
|
|
|
|
|
|
call delete('Xapple')
|
|
|
|
|
call delete('Xapple.swp')
|
|
|
|
|
augroup grep
|
|
|
|
|
au! SwapExists
|
|
|
|
|
augroup END
|
|
|
|
|
unlet g:ignoreSwapExists
|
|
|
|
|
endfunc
|
2020-09-12 22:33:53 -07:00
|
|
|
|
|
2017-12-18 12:36:13 -07:00
|
|
|
|
func XfreeTests(cchar)
|
|
|
|
|
call s:setup_commands(a:cchar)
|
|
|
|
|
|
|
|
|
|
enew | only
|
|
|
|
|
|
|
|
|
|
" Deleting the quickfix stack should work even When the current list is
|
|
|
|
|
" somewhere in the middle of the stack
|
|
|
|
|
Xexpr ['Xfile1:10:10:Line 10', 'Xfile1:15:15:Line 15']
|
|
|
|
|
Xexpr ['Xfile2:20:20:Line 20', 'Xfile2:25:25:Line 25']
|
|
|
|
|
Xexpr ['Xfile3:30:30:Line 30', 'Xfile3:35:35:Line 35']
|
|
|
|
|
Xolder
|
|
|
|
|
call g:Xsetlist([], 'f')
|
|
|
|
|
call assert_equal(0, len(g:Xgetlist()))
|
|
|
|
|
|
|
|
|
|
" After deleting the stack, adding a new list should create a stack with a
|
|
|
|
|
" single list.
|
|
|
|
|
Xexpr ['Xfile1:10:10:Line 10', 'Xfile1:15:15:Line 15']
|
|
|
|
|
call assert_equal(1, g:Xgetlist({'all':1}).nr)
|
|
|
|
|
|
|
|
|
|
" Deleting the stack from a quickfix window should update/clear the
|
|
|
|
|
" quickfix/location list window.
|
|
|
|
|
Xexpr ['Xfile1:10:10:Line 10', 'Xfile1:15:15:Line 15']
|
|
|
|
|
Xexpr ['Xfile2:20:20:Line 20', 'Xfile2:25:25:Line 25']
|
|
|
|
|
Xexpr ['Xfile3:30:30:Line 30', 'Xfile3:35:35:Line 35']
|
|
|
|
|
Xolder
|
|
|
|
|
Xwindow
|
|
|
|
|
call g:Xsetlist([], 'f')
|
|
|
|
|
call assert_equal(2, winnr('$'))
|
|
|
|
|
call assert_equal(1, line('$'))
|
|
|
|
|
Xclose
|
|
|
|
|
|
|
|
|
|
" Deleting the stack from a non-quickfix window should update/clear the
|
|
|
|
|
" quickfix/location list window.
|
|
|
|
|
Xexpr ['Xfile1:10:10:Line 10', 'Xfile1:15:15:Line 15']
|
|
|
|
|
Xexpr ['Xfile2:20:20:Line 20', 'Xfile2:25:25:Line 25']
|
|
|
|
|
Xexpr ['Xfile3:30:30:Line 30', 'Xfile3:35:35:Line 35']
|
|
|
|
|
Xolder
|
|
|
|
|
Xwindow
|
|
|
|
|
wincmd p
|
|
|
|
|
call g:Xsetlist([], 'f')
|
|
|
|
|
call assert_equal(0, len(g:Xgetlist()))
|
|
|
|
|
wincmd p
|
|
|
|
|
call assert_equal(2, winnr('$'))
|
|
|
|
|
call assert_equal(1, line('$'))
|
|
|
|
|
|
|
|
|
|
" After deleting the location list stack, if the location list window is
|
|
|
|
|
" opened, then a new location list should be created. So opening the
|
|
|
|
|
" location list window again should not create a new window.
|
|
|
|
|
if a:cchar == 'l'
|
|
|
|
|
lexpr ['Xfile1:10:10:Line 10', 'Xfile1:15:15:Line 15']
|
|
|
|
|
wincmd p
|
|
|
|
|
lopen
|
|
|
|
|
call assert_equal(2, winnr('$'))
|
|
|
|
|
endif
|
|
|
|
|
Xclose
|
|
|
|
|
endfunc
|
|
|
|
|
|
2019-06-05 19:52:38 -07:00
|
|
|
|
" Tests for the quickfix free functionality
|
2017-12-18 12:36:13 -07:00
|
|
|
|
func Test_qf_free()
|
|
|
|
|
call XfreeTests('c')
|
|
|
|
|
call XfreeTests('l')
|
|
|
|
|
endfunc
|
2017-12-19 08:53:59 -07:00
|
|
|
|
|
|
|
|
|
" Test for buffer overflow when parsing lines and adding new entries to
|
|
|
|
|
" the quickfix list.
|
|
|
|
|
func Test_bufoverflow()
|
|
|
|
|
set efm=%f:%l:%m
|
|
|
|
|
cgetexpr ['File1:100:' . repeat('x', 1025)]
|
|
|
|
|
|
|
|
|
|
set efm=%+GCompiler:\ %.%#,%f:%l:%m
|
|
|
|
|
cgetexpr ['Compiler: ' . repeat('a', 1015), 'File1:10:Hello World']
|
|
|
|
|
|
|
|
|
|
set efm=%DEntering\ directory\ %f,%f:%l:%m
|
|
|
|
|
cgetexpr ['Entering directory ' . repeat('a', 1006),
|
|
|
|
|
\ 'File1:10:Hello World']
|
|
|
|
|
set efm&vim
|
|
|
|
|
endfunc
|
|
|
|
|
|
2017-12-30 21:39:51 -07:00
|
|
|
|
" Tests for getting the quickfix stack size
|
|
|
|
|
func XsizeTests(cchar)
|
|
|
|
|
call s:setup_commands(a:cchar)
|
|
|
|
|
|
|
|
|
|
call g:Xsetlist([], 'f')
|
|
|
|
|
call assert_equal(0, g:Xgetlist({'nr':'$'}).nr)
|
2019-04-19 09:54:56 -07:00
|
|
|
|
call assert_equal('', g:Xgetlist({'nr':'$', 'all':1}).title)
|
|
|
|
|
call assert_equal(0, g:Xgetlist({'nr':0}).nr)
|
2017-12-30 21:39:51 -07:00
|
|
|
|
|
|
|
|
|
Xexpr "File1:10:Line1"
|
|
|
|
|
Xexpr "File2:20:Line2"
|
|
|
|
|
Xexpr "File3:30:Line3"
|
|
|
|
|
Xolder | Xolder
|
|
|
|
|
call assert_equal(3, g:Xgetlist({'nr':'$'}).nr)
|
|
|
|
|
call g:Xsetlist([], 'f')
|
|
|
|
|
|
|
|
|
|
Xexpr "File1:10:Line1"
|
|
|
|
|
Xexpr "File2:20:Line2"
|
|
|
|
|
Xexpr "File3:30:Line3"
|
|
|
|
|
Xolder | Xolder
|
|
|
|
|
call g:Xsetlist([], 'a', {'nr':'$', 'title':'Compiler'})
|
|
|
|
|
call assert_equal('Compiler', g:Xgetlist({'nr':3, 'all':1}).title)
|
|
|
|
|
endfunc
|
|
|
|
|
|
|
|
|
|
func Test_Qf_Size()
|
|
|
|
|
call XsizeTests('c')
|
|
|
|
|
call XsizeTests('l')
|
|
|
|
|
endfunc
|
2018-06-25 16:32:35 -07:00
|
|
|
|
|
2018-06-25 16:42:55 -07:00
|
|
|
|
func Test_cclose_from_copen()
|
|
|
|
|
augroup QF_Test
|
|
|
|
|
au!
|
|
|
|
|
au FileType qf :call assert_fails(':cclose', 'E788')
|
|
|
|
|
augroup END
|
|
|
|
|
copen
|
|
|
|
|
augroup QF_Test
|
|
|
|
|
au!
|
|
|
|
|
augroup END
|
|
|
|
|
augroup! QF_Test
|
|
|
|
|
endfunc
|
|
|
|
|
|
2018-06-25 16:32:35 -07:00
|
|
|
|
func Test_cclose_in_autocmd()
|
2022-11-28 05:01:36 -07:00
|
|
|
|
" Problem is only triggered if "starting" is zero, so that the OptionSet
|
2018-06-25 16:32:35 -07:00
|
|
|
|
" event will be triggered.
|
|
|
|
|
" call test_override('starting', 1)
|
|
|
|
|
augroup QF_Test
|
|
|
|
|
au!
|
|
|
|
|
au FileType qf :call assert_fails(':cclose', 'E788')
|
|
|
|
|
augroup END
|
|
|
|
|
copen
|
|
|
|
|
augroup QF_Test
|
|
|
|
|
au!
|
|
|
|
|
augroup END
|
|
|
|
|
augroup! QF_Test
|
|
|
|
|
" call test_override('starting', 0)
|
|
|
|
|
endfunc
|
2018-06-25 16:42:55 -07:00
|
|
|
|
|
2022-10-22 18:45:39 -07:00
|
|
|
|
" Check that ":file" without an argument is possible even when "curbuf->b_ro_locked"
|
2018-11-09 01:33:28 -07:00
|
|
|
|
" is set.
|
|
|
|
|
func Test_file_from_copen()
|
|
|
|
|
" Works without argument.
|
|
|
|
|
augroup QF_Test
|
|
|
|
|
au!
|
|
|
|
|
au FileType qf file
|
|
|
|
|
augroup END
|
|
|
|
|
copen
|
|
|
|
|
|
|
|
|
|
augroup QF_Test
|
|
|
|
|
au!
|
|
|
|
|
augroup END
|
|
|
|
|
cclose
|
|
|
|
|
|
|
|
|
|
" Fails with argument.
|
|
|
|
|
augroup QF_Test
|
|
|
|
|
au!
|
|
|
|
|
au FileType qf call assert_fails(':file foo', 'E788')
|
|
|
|
|
augroup END
|
|
|
|
|
copen
|
|
|
|
|
augroup QF_Test
|
|
|
|
|
au!
|
|
|
|
|
augroup END
|
|
|
|
|
cclose
|
|
|
|
|
|
|
|
|
|
augroup! QF_Test
|
2019-10-26 17:06:29 -07:00
|
|
|
|
endfunc
|
2018-11-09 01:33:28 -07:00
|
|
|
|
|
2018-06-25 16:42:55 -07:00
|
|
|
|
func Test_resize_from_copen()
|
2022-07-16 22:11:46 -07:00
|
|
|
|
augroup QF_Test
|
|
|
|
|
au!
|
|
|
|
|
au FileType qf resize 5
|
|
|
|
|
augroup END
|
|
|
|
|
try
|
|
|
|
|
" This should succeed without any exception. No other buffers are
|
|
|
|
|
" involved in the autocmd.
|
|
|
|
|
copen
|
|
|
|
|
finally
|
2018-06-25 16:42:55 -07:00
|
|
|
|
augroup QF_Test
|
2022-07-16 22:11:46 -07:00
|
|
|
|
au!
|
2018-06-25 16:42:55 -07:00
|
|
|
|
augroup END
|
2022-07-16 22:11:46 -07:00
|
|
|
|
augroup! QF_Test
|
|
|
|
|
endtry
|
|
|
|
|
endfunc
|
|
|
|
|
|
2022-12-02 12:40:31 -07:00
|
|
|
|
func Test_filetype_autocmd()
|
|
|
|
|
" this changes the location list while it is in use to fill a buffer
|
|
|
|
|
lexpr ''
|
|
|
|
|
lopen
|
|
|
|
|
augroup FT_loclist
|
|
|
|
|
au FileType * call setloclist(0, [], 'f')
|
|
|
|
|
augroup END
|
|
|
|
|
silent! lolder
|
|
|
|
|
lexpr ''
|
|
|
|
|
|
|
|
|
|
augroup FT_loclist
|
|
|
|
|
au! FileType
|
|
|
|
|
augroup END
|
|
|
|
|
endfunc
|
|
|
|
|
|
2022-07-16 22:11:46 -07:00
|
|
|
|
func Test_vimgrep_with_textlock()
|
|
|
|
|
new
|
|
|
|
|
|
2022-07-16 20:47:34 -07:00
|
|
|
|
" Simple way to execute something with "textlock" set.
|
2022-07-16 22:11:46 -07:00
|
|
|
|
" Check that vimgrep without jumping can be executed.
|
|
|
|
|
au InsertCharPre * vimgrep /RunTheTest/j runtest.vim
|
|
|
|
|
normal ax
|
|
|
|
|
let qflist = getqflist()
|
|
|
|
|
call assert_true(len(qflist) > 0)
|
|
|
|
|
call assert_match('RunTheTest', qflist[0].text)
|
|
|
|
|
call setqflist([], 'r')
|
|
|
|
|
au! InsertCharPre
|
|
|
|
|
|
|
|
|
|
" Check that vimgrepadd without jumping can be executed.
|
|
|
|
|
au InsertCharPre * vimgrepadd /RunTheTest/j runtest.vim
|
|
|
|
|
normal ax
|
|
|
|
|
let qflist = getqflist()
|
|
|
|
|
call assert_true(len(qflist) > 0)
|
|
|
|
|
call assert_match('RunTheTest', qflist[0].text)
|
|
|
|
|
call setqflist([], 'r')
|
|
|
|
|
au! InsertCharPre
|
|
|
|
|
|
|
|
|
|
" Check that lvimgrep without jumping can be executed.
|
|
|
|
|
au InsertCharPre * lvimgrep /RunTheTest/j runtest.vim
|
|
|
|
|
normal ax
|
|
|
|
|
let qflist = getloclist(0)
|
|
|
|
|
call assert_true(len(qflist) > 0)
|
|
|
|
|
call assert_match('RunTheTest', qflist[0].text)
|
|
|
|
|
call setloclist(0, [], 'r')
|
|
|
|
|
au! InsertCharPre
|
|
|
|
|
|
|
|
|
|
" Check that lvimgrepadd without jumping can be executed.
|
|
|
|
|
au InsertCharPre * lvimgrepadd /RunTheTest/j runtest.vim
|
|
|
|
|
normal ax
|
|
|
|
|
let qflist = getloclist(0)
|
|
|
|
|
call assert_true(len(qflist) > 0)
|
|
|
|
|
call assert_match('RunTheTest', qflist[0].text)
|
|
|
|
|
call setloclist(0, [], 'r')
|
|
|
|
|
au! InsertCharPre
|
|
|
|
|
|
|
|
|
|
" trying to jump will give an error
|
|
|
|
|
au InsertCharPre * vimgrep /RunTheTest/ runtest.vim
|
|
|
|
|
call assert_fails('normal ax', 'E565:')
|
|
|
|
|
au! InsertCharPre
|
|
|
|
|
|
|
|
|
|
au InsertCharPre * vimgrepadd /RunTheTest/ runtest.vim
|
|
|
|
|
call assert_fails('normal ax', 'E565:')
|
|
|
|
|
au! InsertCharPre
|
|
|
|
|
|
|
|
|
|
au InsertCharPre * lvimgrep /RunTheTest/ runtest.vim
|
|
|
|
|
call assert_fails('normal ax', 'E565:')
|
|
|
|
|
au! InsertCharPre
|
|
|
|
|
|
|
|
|
|
au InsertCharPre * lvimgrepadd /RunTheTest/ runtest.vim
|
|
|
|
|
call assert_fails('normal ax', 'E565:')
|
|
|
|
|
au! InsertCharPre
|
|
|
|
|
|
|
|
|
|
bwipe!
|
2018-06-25 16:42:55 -07:00
|
|
|
|
endfunc
|
2018-07-28 20:53:41 -07:00
|
|
|
|
|
|
|
|
|
" Tests for the quickfix buffer b:changedtick variable
|
|
|
|
|
func Xchangedtick_tests(cchar)
|
|
|
|
|
call s:setup_commands(a:cchar)
|
|
|
|
|
|
|
|
|
|
new | only
|
|
|
|
|
|
|
|
|
|
Xexpr "" | Xexpr "" | Xexpr ""
|
|
|
|
|
|
|
|
|
|
Xopen
|
|
|
|
|
Xolder
|
|
|
|
|
Xolder
|
|
|
|
|
Xaddexpr "F1:10:Line10"
|
|
|
|
|
Xaddexpr "F2:20:Line20"
|
|
|
|
|
call g:Xsetlist([{"filename":"F3", "lnum":30, "text":"Line30"}], 'a')
|
|
|
|
|
call g:Xsetlist([], 'f')
|
|
|
|
|
call assert_equal(8, getbufvar('%', 'changedtick'))
|
|
|
|
|
Xclose
|
|
|
|
|
endfunc
|
|
|
|
|
|
|
|
|
|
func Test_changedtick()
|
2018-09-06 18:54:30 -07:00
|
|
|
|
call Xchangedtick_tests('c')
|
|
|
|
|
call Xchangedtick_tests('l')
|
|
|
|
|
endfunc
|
|
|
|
|
|
|
|
|
|
" Tests for parsing an expression using setqflist()
|
|
|
|
|
func Xsetexpr_tests(cchar)
|
|
|
|
|
call s:setup_commands(a:cchar)
|
|
|
|
|
|
|
|
|
|
let t = ["File1:10:Line10", "File1:20:Line20"]
|
2018-09-08 08:19:55 -07:00
|
|
|
|
call g:Xsetlist([], ' ', {'lines' : t})
|
|
|
|
|
call g:Xsetlist([], 'a', {'lines' : ["File1:30:Line30"]})
|
2018-09-06 18:54:30 -07:00
|
|
|
|
|
|
|
|
|
let l = g:Xgetlist()
|
|
|
|
|
call assert_equal(3, len(l))
|
|
|
|
|
call assert_equal(20, l[1].lnum)
|
|
|
|
|
call assert_equal('Line30', l[2].text)
|
2018-09-08 08:19:55 -07:00
|
|
|
|
call g:Xsetlist([], 'r', {'lines' : ["File2:5:Line5"]})
|
2018-09-06 18:54:30 -07:00
|
|
|
|
let l = g:Xgetlist()
|
|
|
|
|
call assert_equal(1, len(l))
|
|
|
|
|
call assert_equal('Line5', l[0].text)
|
2018-09-08 08:19:55 -07:00
|
|
|
|
call assert_equal(-1, g:Xsetlist([], 'a', {'lines' : 10}))
|
|
|
|
|
call assert_equal(-1, g:Xsetlist([], 'a', {'lines' : "F1:10:L10"}))
|
2018-09-06 18:54:30 -07:00
|
|
|
|
|
|
|
|
|
call g:Xsetlist([], 'f')
|
|
|
|
|
" Add entries to multiple lists
|
2018-09-08 08:19:55 -07:00
|
|
|
|
call g:Xsetlist([], 'a', {'nr' : 1, 'lines' : ["File1:10:Line10"]})
|
|
|
|
|
call g:Xsetlist([], 'a', {'nr' : 2, 'lines' : ["File2:20:Line20"]})
|
|
|
|
|
call g:Xsetlist([], 'a', {'nr' : 1, 'lines' : ["File1:15:Line15"]})
|
|
|
|
|
call g:Xsetlist([], 'a', {'nr' : 2, 'lines' : ["File2:25:Line25"]})
|
2018-09-06 18:54:30 -07:00
|
|
|
|
call assert_equal('Line15', g:Xgetlist({'nr':1, 'items':1}).items[1].text)
|
|
|
|
|
call assert_equal('Line25', g:Xgetlist({'nr':2, 'items':1}).items[1].text)
|
2018-09-08 08:37:59 -07:00
|
|
|
|
|
|
|
|
|
" Adding entries using a custom efm
|
|
|
|
|
set efm&
|
|
|
|
|
call g:Xsetlist([], ' ', {'efm' : '%f#%l#%m',
|
|
|
|
|
\ 'lines' : ["F1#10#L10", "F2#20#L20"]})
|
|
|
|
|
call assert_equal(20, g:Xgetlist({'items':1}).items[1].lnum)
|
|
|
|
|
call g:Xsetlist([], 'a', {'efm' : '%f#%l#%m', 'lines' : ["F3:30:L30"]})
|
|
|
|
|
call assert_equal('F3:30:L30', g:Xgetlist({'items':1}).items[2].text)
|
|
|
|
|
call assert_equal(20, g:Xgetlist({'items':1}).items[1].lnum)
|
|
|
|
|
call assert_equal(-1, g:Xsetlist([], 'a', {'efm' : [],
|
|
|
|
|
\ 'lines' : ['F1:10:L10']}))
|
2018-09-06 18:54:30 -07:00
|
|
|
|
endfunc
|
|
|
|
|
|
|
|
|
|
func Test_setexpr()
|
|
|
|
|
call Xsetexpr_tests('c')
|
|
|
|
|
call Xsetexpr_tests('l')
|
|
|
|
|
endfunc
|
|
|
|
|
|
|
|
|
|
" Tests for per quickfix/location list directory stack
|
|
|
|
|
func Xmultidirstack_tests(cchar)
|
|
|
|
|
call s:setup_commands(a:cchar)
|
|
|
|
|
|
|
|
|
|
call g:Xsetlist([], 'f')
|
|
|
|
|
Xexpr "" | Xexpr ""
|
|
|
|
|
|
2018-09-08 08:19:55 -07:00
|
|
|
|
call g:Xsetlist([], 'a', {'nr' : 1, 'lines' : ["Entering dir 'Xone/a'"]})
|
|
|
|
|
call g:Xsetlist([], 'a', {'nr' : 2, 'lines' : ["Entering dir 'Xtwo/a'"]})
|
|
|
|
|
call g:Xsetlist([], 'a', {'nr' : 1, 'lines' : ["one.txt:3:one one one"]})
|
|
|
|
|
call g:Xsetlist([], 'a', {'nr' : 2, 'lines' : ["two.txt:5:two two two"]})
|
2018-09-06 18:54:30 -07:00
|
|
|
|
|
|
|
|
|
let l1 = g:Xgetlist({'nr':1, 'items':1})
|
|
|
|
|
let l2 = g:Xgetlist({'nr':2, 'items':1})
|
2022-11-09 22:38:17 -07:00
|
|
|
|
call assert_equal('Xone/a/one.txt', bufname(l1.items[1].bufnr))
|
2018-09-06 18:54:30 -07:00
|
|
|
|
call assert_equal(3, l1.items[1].lnum)
|
2022-11-09 22:38:17 -07:00
|
|
|
|
call assert_equal('Xtwo/a/two.txt', bufname(l2.items[1].bufnr))
|
2018-09-06 18:54:30 -07:00
|
|
|
|
call assert_equal(5, l2.items[1].lnum)
|
|
|
|
|
endfunc
|
|
|
|
|
|
|
|
|
|
func Test_multidirstack()
|
|
|
|
|
call mkdir('Xone/a', 'p')
|
|
|
|
|
call mkdir('Xtwo/a', 'p')
|
|
|
|
|
let lines = ['1', '2', 'one one one', '4', 'two two two', '6', '7']
|
|
|
|
|
call writefile(lines, 'Xone/a/one.txt')
|
|
|
|
|
call writefile(lines, 'Xtwo/a/two.txt')
|
|
|
|
|
let save_efm = &efm
|
|
|
|
|
set efm=%DEntering\ dir\ '%f',%f:%l:%m,%XLeaving\ dir\ '%f'
|
|
|
|
|
|
|
|
|
|
call Xmultidirstack_tests('c')
|
|
|
|
|
call Xmultidirstack_tests('l')
|
|
|
|
|
|
|
|
|
|
let &efm = save_efm
|
|
|
|
|
call delete('Xone', 'rf')
|
|
|
|
|
call delete('Xtwo', 'rf')
|
|
|
|
|
endfunc
|
|
|
|
|
|
|
|
|
|
" Tests for per quickfix/location list file stack
|
|
|
|
|
func Xmultifilestack_tests(cchar)
|
|
|
|
|
call s:setup_commands(a:cchar)
|
|
|
|
|
|
|
|
|
|
call g:Xsetlist([], 'f')
|
|
|
|
|
Xexpr "" | Xexpr ""
|
|
|
|
|
|
2018-09-08 08:19:55 -07:00
|
|
|
|
call g:Xsetlist([], 'a', {'nr' : 1, 'lines' : ["[one.txt]"]})
|
|
|
|
|
call g:Xsetlist([], 'a', {'nr' : 2, 'lines' : ["[two.txt]"]})
|
|
|
|
|
call g:Xsetlist([], 'a', {'nr' : 1, 'lines' : ["(3,5) one one one"]})
|
|
|
|
|
call g:Xsetlist([], 'a', {'nr' : 2, 'lines' : ["(5,9) two two two"]})
|
2018-09-06 18:54:30 -07:00
|
|
|
|
|
|
|
|
|
let l1 = g:Xgetlist({'nr':1, 'items':1})
|
|
|
|
|
let l2 = g:Xgetlist({'nr':2, 'items':1})
|
|
|
|
|
call assert_equal('one.txt', bufname(l1.items[1].bufnr))
|
|
|
|
|
call assert_equal(3, l1.items[1].lnum)
|
|
|
|
|
call assert_equal('two.txt', bufname(l2.items[1].bufnr))
|
|
|
|
|
call assert_equal(5, l2.items[1].lnum)
|
2019-04-05 01:57:57 -07:00
|
|
|
|
|
|
|
|
|
" Test for start of a new error line in the same line where a previous
|
|
|
|
|
" error line ends with a file stack.
|
|
|
|
|
let efm_val = 'Error\ l%l\ in\ %f,'
|
|
|
|
|
let efm_val .= '%-P%>(%f%r,Error\ l%l\ in\ %m,%-Q)%r'
|
2022-10-12 23:31:10 -07:00
|
|
|
|
let lines =<< trim END
|
|
|
|
|
(one.txt
|
|
|
|
|
Error l4 in one.txt
|
|
|
|
|
) (two.txt
|
|
|
|
|
Error l6 in two.txt
|
|
|
|
|
)
|
|
|
|
|
Error l8 in one.txt
|
|
|
|
|
END
|
|
|
|
|
let l = g:Xgetlist({'lines': lines, 'efm' : efm_val})
|
2019-04-05 01:57:57 -07:00
|
|
|
|
call assert_equal(3, len(l.items))
|
|
|
|
|
call assert_equal('one.txt', bufname(l.items[0].bufnr))
|
|
|
|
|
call assert_equal(4, l.items[0].lnum)
|
|
|
|
|
call assert_equal('one.txt', l.items[0].text)
|
|
|
|
|
call assert_equal('two.txt', bufname(l.items[1].bufnr))
|
|
|
|
|
call assert_equal(6, l.items[1].lnum)
|
|
|
|
|
call assert_equal('two.txt', l.items[1].text)
|
|
|
|
|
call assert_equal('one.txt', bufname(l.items[2].bufnr))
|
|
|
|
|
call assert_equal(8, l.items[2].lnum)
|
|
|
|
|
call assert_equal('', l.items[2].text)
|
2018-09-06 18:54:30 -07:00
|
|
|
|
endfunc
|
|
|
|
|
|
|
|
|
|
func Test_multifilestack()
|
|
|
|
|
let lines = ['1', '2', 'one one one', '4', 'two two two', '6', '7']
|
|
|
|
|
call writefile(lines, 'one.txt')
|
|
|
|
|
call writefile(lines, 'two.txt')
|
|
|
|
|
let save_efm = &efm
|
|
|
|
|
set efm=%+P[%f],(%l\\,%c)\ %m,%-Q
|
|
|
|
|
|
|
|
|
|
call Xmultifilestack_tests('c')
|
|
|
|
|
call Xmultifilestack_tests('l')
|
|
|
|
|
|
|
|
|
|
let &efm = save_efm
|
|
|
|
|
call delete('one.txt')
|
|
|
|
|
call delete('two.txt')
|
|
|
|
|
endfunc
|
|
|
|
|
|
|
|
|
|
" Tests for per buffer 'efm' setting
|
|
|
|
|
func Test_perbuf_efm()
|
|
|
|
|
call writefile(["File1-10-Line10"], 'one.txt')
|
|
|
|
|
call writefile(["File2#20#Line20"], 'two.txt')
|
|
|
|
|
set efm=%f#%l#%m
|
|
|
|
|
new | only
|
|
|
|
|
new
|
|
|
|
|
setlocal efm=%f-%l-%m
|
|
|
|
|
cfile one.txt
|
|
|
|
|
wincmd w
|
|
|
|
|
caddfile two.txt
|
|
|
|
|
|
|
|
|
|
let l = getqflist()
|
|
|
|
|
call assert_equal(10, l[0].lnum)
|
|
|
|
|
call assert_equal('Line20', l[1].text)
|
|
|
|
|
|
|
|
|
|
set efm&
|
|
|
|
|
new | only
|
|
|
|
|
call delete('one.txt')
|
|
|
|
|
call delete('two.txt')
|
2018-07-28 20:53:41 -07:00
|
|
|
|
endfunc
|
2018-09-06 02:08:15 -07:00
|
|
|
|
|
|
|
|
|
" Open multiple help windows using ":lhelpgrep
|
|
|
|
|
" This test used to crash Vim
|
|
|
|
|
func Test_Multi_LL_Help()
|
|
|
|
|
new | only
|
|
|
|
|
lhelpgrep window
|
|
|
|
|
lopen
|
|
|
|
|
e#
|
|
|
|
|
lhelpgrep buffer
|
|
|
|
|
call assert_equal(3, winnr('$'))
|
|
|
|
|
call assert_true(len(getloclist(1)) != 0)
|
|
|
|
|
call assert_true(len(getloclist(2)) != 0)
|
|
|
|
|
new | only
|
|
|
|
|
endfunc
|
2018-09-06 20:49:21 -07:00
|
|
|
|
|
|
|
|
|
" Tests for adding new quickfix lists using setqflist()
|
|
|
|
|
func XaddQf_tests(cchar)
|
|
|
|
|
call s:setup_commands(a:cchar)
|
|
|
|
|
|
|
|
|
|
" Create a new list using ' ' for action
|
|
|
|
|
call g:Xsetlist([], 'f')
|
|
|
|
|
call g:Xsetlist([], ' ', {'title' : 'Test1'})
|
|
|
|
|
let l = g:Xgetlist({'nr' : '$', 'all' : 1})
|
|
|
|
|
call assert_equal(1, l.nr)
|
|
|
|
|
call assert_equal('Test1', l.title)
|
|
|
|
|
|
|
|
|
|
" Create a new list using ' ' for action and '$' for 'nr'
|
|
|
|
|
call g:Xsetlist([], 'f')
|
|
|
|
|
call g:Xsetlist([], ' ', {'title' : 'Test2', 'nr' : '$'})
|
|
|
|
|
let l = g:Xgetlist({'nr' : '$', 'all' : 1})
|
|
|
|
|
call assert_equal(1, l.nr)
|
|
|
|
|
call assert_equal('Test2', l.title)
|
|
|
|
|
|
|
|
|
|
" Create a new list using 'a' for action
|
|
|
|
|
call g:Xsetlist([], 'f')
|
|
|
|
|
call g:Xsetlist([], 'a', {'title' : 'Test3'})
|
|
|
|
|
let l = g:Xgetlist({'nr' : '$', 'all' : 1})
|
|
|
|
|
call assert_equal(1, l.nr)
|
|
|
|
|
call assert_equal('Test3', l.title)
|
|
|
|
|
|
|
|
|
|
" Create a new list using 'a' for action and '$' for 'nr'
|
|
|
|
|
call g:Xsetlist([], 'f')
|
|
|
|
|
call g:Xsetlist([], 'a', {'title' : 'Test3', 'nr' : '$'})
|
|
|
|
|
call g:Xsetlist([], 'a', {'title' : 'Test4'})
|
|
|
|
|
let l = g:Xgetlist({'nr' : '$', 'all' : 1})
|
|
|
|
|
call assert_equal(1, l.nr)
|
|
|
|
|
call assert_equal('Test4', l.title)
|
|
|
|
|
|
|
|
|
|
" Adding a quickfix list should remove all the lists following the current
|
|
|
|
|
" list.
|
|
|
|
|
Xexpr "" | Xexpr "" | Xexpr ""
|
|
|
|
|
silent! 10Xolder
|
|
|
|
|
call g:Xsetlist([], ' ', {'title' : 'Test5'})
|
|
|
|
|
let l = g:Xgetlist({'nr' : '$', 'all' : 1})
|
|
|
|
|
call assert_equal(2, l.nr)
|
|
|
|
|
call assert_equal('Test5', l.title)
|
|
|
|
|
|
|
|
|
|
" Add a quickfix list using '$' as the list number.
|
|
|
|
|
let lastqf = g:Xgetlist({'nr':'$'}).nr
|
|
|
|
|
silent! 99Xolder
|
|
|
|
|
call g:Xsetlist([], ' ', {'nr' : '$', 'title' : 'Test6'})
|
|
|
|
|
let l = g:Xgetlist({'nr' : '$', 'all' : 1})
|
|
|
|
|
call assert_equal(lastqf + 1, l.nr)
|
|
|
|
|
call assert_equal('Test6', l.title)
|
|
|
|
|
|
|
|
|
|
" Add a quickfix list using 'nr' set to one more than the quickfix
|
|
|
|
|
" list size.
|
|
|
|
|
let lastqf = g:Xgetlist({'nr':'$'}).nr
|
|
|
|
|
silent! 99Xolder
|
|
|
|
|
call g:Xsetlist([], ' ', {'nr' : lastqf + 1, 'title' : 'Test7'})
|
|
|
|
|
let l = g:Xgetlist({'nr' : '$', 'all' : 1})
|
|
|
|
|
call assert_equal(lastqf + 1, l.nr)
|
|
|
|
|
call assert_equal('Test7', l.title)
|
|
|
|
|
|
|
|
|
|
" Add a quickfix list to a stack with 10 lists using 'nr' set to '$'
|
|
|
|
|
exe repeat('Xexpr "" |', 9) . 'Xexpr ""'
|
|
|
|
|
silent! 99Xolder
|
|
|
|
|
call g:Xsetlist([], ' ', {'nr' : '$', 'title' : 'Test8'})
|
|
|
|
|
let l = g:Xgetlist({'nr' : '$', 'all' : 1})
|
|
|
|
|
call assert_equal(10, l.nr)
|
|
|
|
|
call assert_equal('Test8', l.title)
|
|
|
|
|
|
|
|
|
|
" Add a quickfix list using 'nr' set to a value greater than 10
|
|
|
|
|
call assert_equal(-1, g:Xsetlist([], ' ', {'nr' : 12, 'title' : 'Test9'}))
|
|
|
|
|
|
|
|
|
|
" Try adding a quickfix list with 'nr' set to a value greater than the
|
|
|
|
|
" quickfix list size but less than 10.
|
|
|
|
|
call g:Xsetlist([], 'f')
|
|
|
|
|
Xexpr "" | Xexpr "" | Xexpr ""
|
|
|
|
|
silent! 99Xolder
|
|
|
|
|
call assert_equal(-1, g:Xsetlist([], ' ', {'nr' : 8, 'title' : 'Test10'}))
|
|
|
|
|
|
|
|
|
|
" Add a quickfix list using 'nr' set to a some string or list
|
|
|
|
|
call assert_equal(-1, g:Xsetlist([], ' ', {'nr' : [1,2], 'title' : 'Test11'}))
|
|
|
|
|
endfunc
|
|
|
|
|
|
|
|
|
|
func Test_add_qf()
|
|
|
|
|
call XaddQf_tests('c')
|
|
|
|
|
call XaddQf_tests('l')
|
|
|
|
|
endfunc
|
2018-09-07 19:22:37 -07:00
|
|
|
|
|
|
|
|
|
" Test for getting the quickfix list items from some text without modifying
|
|
|
|
|
" the quickfix stack
|
2018-09-08 08:19:55 -07:00
|
|
|
|
func XgetListFromLines(cchar)
|
2018-09-07 19:22:37 -07:00
|
|
|
|
call s:setup_commands(a:cchar)
|
|
|
|
|
call g:Xsetlist([], 'f')
|
|
|
|
|
|
2018-09-08 08:19:55 -07:00
|
|
|
|
let l = g:Xgetlist({'lines' : ["File2:20:Line20", "File2:30:Line30"]}).items
|
2018-09-07 19:22:37 -07:00
|
|
|
|
call assert_equal(2, len(l))
|
|
|
|
|
call assert_equal(30, l[1].lnum)
|
|
|
|
|
|
2018-09-08 08:19:55 -07:00
|
|
|
|
call assert_equal({}, g:Xgetlist({'lines' : 10}))
|
|
|
|
|
call assert_equal({}, g:Xgetlist({'lines' : 'File1:10:Line10'}))
|
|
|
|
|
call assert_equal([], g:Xgetlist({'lines' : []}).items)
|
|
|
|
|
call assert_equal([], g:Xgetlist({'lines' : [10, 20]}).items)
|
2018-09-07 19:22:37 -07:00
|
|
|
|
|
2018-09-08 08:37:59 -07:00
|
|
|
|
" Parse text using a custom efm
|
|
|
|
|
set efm&
|
|
|
|
|
let l = g:Xgetlist({'lines':['File3#30#Line30'], 'efm' : '%f#%l#%m'}).items
|
|
|
|
|
call assert_equal('Line30', l[0].text)
|
|
|
|
|
let l = g:Xgetlist({'lines':['File3:30:Line30'], 'efm' : '%f-%l-%m'}).items
|
|
|
|
|
call assert_equal('File3:30:Line30', l[0].text)
|
|
|
|
|
let l = g:Xgetlist({'lines':['File3:30:Line30'], 'efm' : [1,2]})
|
|
|
|
|
call assert_equal({}, l)
|
|
|
|
|
call assert_fails("call g:Xgetlist({'lines':['abc'], 'efm':'%2'})", 'E376:')
|
|
|
|
|
call assert_fails("call g:Xgetlist({'lines':['abc'], 'efm':''})", 'E378:')
|
|
|
|
|
|
2018-09-07 19:22:37 -07:00
|
|
|
|
" Make sure that the quickfix stack is not modified
|
|
|
|
|
call assert_equal(0, g:Xgetlist({'nr' : '$'}).nr)
|
|
|
|
|
endfunc
|
|
|
|
|
|
2018-09-08 08:19:55 -07:00
|
|
|
|
func Test_get_list_from_lines()
|
|
|
|
|
call XgetListFromLines('c')
|
|
|
|
|
call XgetListFromLines('l')
|
2018-09-07 19:22:37 -07:00
|
|
|
|
endfunc
|
2018-09-08 03:13:23 -07:00
|
|
|
|
|
|
|
|
|
" Tests for the quickfix list id
|
|
|
|
|
func Xqfid_tests(cchar)
|
|
|
|
|
call s:setup_commands(a:cchar)
|
|
|
|
|
|
|
|
|
|
call g:Xsetlist([], 'f')
|
2019-04-19 09:54:56 -07:00
|
|
|
|
call assert_equal(0, g:Xgetlist({'id':0}).id)
|
2018-09-08 03:13:23 -07:00
|
|
|
|
Xexpr ''
|
|
|
|
|
let start_id = g:Xgetlist({'id' : 0}).id
|
|
|
|
|
Xexpr '' | Xexpr ''
|
|
|
|
|
Xolder
|
|
|
|
|
call assert_equal(start_id, g:Xgetlist({'id':0, 'nr':1}).id)
|
|
|
|
|
call assert_equal(start_id + 1, g:Xgetlist({'id':0, 'nr':0}).id)
|
|
|
|
|
call assert_equal(start_id + 2, g:Xgetlist({'id':0, 'nr':'$'}).id)
|
2019-04-19 09:54:56 -07:00
|
|
|
|
call assert_equal(0, g:Xgetlist({'id':0, 'nr':99}).id)
|
2018-09-08 03:13:23 -07:00
|
|
|
|
call assert_equal(2, g:Xgetlist({'id':start_id + 1, 'nr':0}).nr)
|
2019-04-19 09:54:56 -07:00
|
|
|
|
call assert_equal(0, g:Xgetlist({'id':99, 'nr':0}).id)
|
|
|
|
|
call assert_equal(0, g:Xgetlist({'id':"abc", 'nr':0}).id)
|
2018-09-08 03:13:23 -07:00
|
|
|
|
|
|
|
|
|
call g:Xsetlist([], 'a', {'id':start_id, 'context':[1,2]})
|
|
|
|
|
call assert_equal([1,2], g:Xgetlist({'nr':1, 'context':1}).context)
|
2018-09-08 08:19:55 -07:00
|
|
|
|
call g:Xsetlist([], 'a', {'id':start_id+1, 'lines':['F1:10:L10']})
|
2018-09-08 03:13:23 -07:00
|
|
|
|
call assert_equal('L10', g:Xgetlist({'nr':2, 'items':1}).items[0].text)
|
|
|
|
|
call assert_equal(-1, g:Xsetlist([], 'a', {'id':999, 'title':'Vim'}))
|
|
|
|
|
call assert_equal(-1, g:Xsetlist([], 'a', {'id':'abc', 'title':'Vim'}))
|
|
|
|
|
|
|
|
|
|
let qfid = g:Xgetlist({'id':0, 'nr':0})
|
|
|
|
|
call g:Xsetlist([], 'f')
|
2019-04-19 09:54:56 -07:00
|
|
|
|
call assert_equal(0, g:Xgetlist({'id':qfid, 'nr':0}).id)
|
2018-09-08 03:13:23 -07:00
|
|
|
|
endfunc
|
|
|
|
|
|
|
|
|
|
func Test_qf_id()
|
|
|
|
|
call Xqfid_tests('c')
|
|
|
|
|
call Xqfid_tests('l')
|
|
|
|
|
endfunc
|
2018-09-07 08:22:52 -07:00
|
|
|
|
|
2019-12-02 09:12:26 -07:00
|
|
|
|
func Xqfjump_tests(cchar)
|
|
|
|
|
call s:setup_commands(a:cchar)
|
2018-11-19 19:10:52 -07:00
|
|
|
|
|
2019-12-02 09:12:26 -07:00
|
|
|
|
call writefile(["Line1\tFoo", "Line2"], 'F1')
|
|
|
|
|
call writefile(["Line1\tBar", "Line2"], 'F2')
|
|
|
|
|
call writefile(["Line1\tBaz", "Line2"], 'F3')
|
2019-04-08 08:00:11 -07:00
|
|
|
|
|
2019-12-02 09:12:26 -07:00
|
|
|
|
call g:Xsetlist([], 'f')
|
2019-04-08 08:00:11 -07:00
|
|
|
|
|
2019-12-02 09:12:26 -07:00
|
|
|
|
" Tests for
|
|
|
|
|
" Jumping to a line using a pattern
|
|
|
|
|
" Jumping to a column greater than the last column in a line
|
|
|
|
|
" Jumping to a line greater than the last line in the file
|
|
|
|
|
let l = []
|
|
|
|
|
for i in range(1, 7)
|
|
|
|
|
call add(l, {})
|
|
|
|
|
endfor
|
|
|
|
|
let l[0].filename='F1'
|
|
|
|
|
let l[0].pattern='Line1'
|
|
|
|
|
let l[1].filename='F2'
|
|
|
|
|
let l[1].pattern='Line1'
|
|
|
|
|
let l[2].filename='F3'
|
|
|
|
|
let l[2].pattern='Line1'
|
|
|
|
|
let l[3].filename='F3'
|
|
|
|
|
let l[3].lnum=1
|
|
|
|
|
let l[3].col=9
|
|
|
|
|
let l[3].vcol=1
|
|
|
|
|
let l[4].filename='F3'
|
|
|
|
|
let l[4].lnum=99
|
|
|
|
|
let l[5].filename='F3'
|
|
|
|
|
let l[5].lnum=1
|
|
|
|
|
let l[5].col=99
|
|
|
|
|
let l[5].vcol=1
|
|
|
|
|
let l[6].filename='F3'
|
|
|
|
|
let l[6].pattern='abcxyz'
|
2019-04-08 08:00:11 -07:00
|
|
|
|
|
2019-12-02 09:12:26 -07:00
|
|
|
|
call g:Xsetlist([], ' ', {'items' : l})
|
|
|
|
|
Xopen | only
|
|
|
|
|
2Xnext
|
|
|
|
|
call assert_equal(3, g:Xgetlist({'idx' : 0}).idx)
|
2022-07-16 18:10:25 -07:00
|
|
|
|
call assert_equal('F3', @%)
|
2019-12-02 09:12:26 -07:00
|
|
|
|
Xnext
|
|
|
|
|
call assert_equal(7, col('.'))
|
|
|
|
|
Xnext
|
|
|
|
|
call assert_equal(2, line('.'))
|
|
|
|
|
Xnext
|
|
|
|
|
call assert_equal(9, col('.'))
|
|
|
|
|
2
|
|
|
|
|
Xnext
|
|
|
|
|
call assert_equal(2, line('.'))
|
2019-04-08 08:00:11 -07:00
|
|
|
|
|
2019-12-02 09:12:26 -07:00
|
|
|
|
if a:cchar == 'l'
|
|
|
|
|
" When jumping to a location list entry in the location list window and
|
|
|
|
|
" no usable windows are available, then a new window should be opened.
|
|
|
|
|
enew! | new | only
|
|
|
|
|
call g:Xsetlist([], 'f')
|
|
|
|
|
setlocal buftype=nofile
|
|
|
|
|
new
|
2022-10-12 23:31:10 -07:00
|
|
|
|
let lines =<< trim END
|
|
|
|
|
F1:1:1:Line1
|
|
|
|
|
F1:2:2:Line2
|
|
|
|
|
F2:1:1:Line1
|
|
|
|
|
F2:2:2:Line2
|
|
|
|
|
F3:1:1:Line1
|
|
|
|
|
F3:2:2:Line2
|
|
|
|
|
END
|
|
|
|
|
call g:Xsetlist([], ' ', {'lines': lines})
|
2019-12-02 09:12:26 -07:00
|
|
|
|
Xopen
|
|
|
|
|
let winid = win_getid()
|
|
|
|
|
wincmd p
|
|
|
|
|
close
|
|
|
|
|
call win_gotoid(winid)
|
|
|
|
|
Xnext
|
|
|
|
|
call assert_equal(3, winnr('$'))
|
|
|
|
|
call assert_equal(1, winnr())
|
|
|
|
|
call assert_equal(2, line('.'))
|
2019-04-08 08:00:11 -07:00
|
|
|
|
|
2019-12-02 09:12:26 -07:00
|
|
|
|
" When jumping to an entry in the location list window and the window
|
|
|
|
|
" associated with the location list is not present and a window containing
|
|
|
|
|
" the file is already present, then that window should be used.
|
|
|
|
|
close
|
|
|
|
|
belowright new
|
|
|
|
|
call g:Xsetlist([], 'f')
|
|
|
|
|
edit F3
|
|
|
|
|
call win_gotoid(winid)
|
|
|
|
|
Xlast
|
|
|
|
|
call assert_equal(3, winnr())
|
|
|
|
|
call assert_equal(6, g:Xgetlist({'size' : 1}).size)
|
|
|
|
|
call assert_equal(winid, g:Xgetlist({'winid' : 1}).winid)
|
|
|
|
|
endif
|
2019-04-08 08:00:11 -07:00
|
|
|
|
|
2019-12-02 09:12:26 -07:00
|
|
|
|
" Cleanup
|
|
|
|
|
enew!
|
|
|
|
|
new | only
|
2019-04-08 08:00:11 -07:00
|
|
|
|
|
2019-12-02 09:12:26 -07:00
|
|
|
|
call delete('F1')
|
|
|
|
|
call delete('F2')
|
|
|
|
|
call delete('F3')
|
|
|
|
|
endfunc
|
2019-04-08 08:00:11 -07:00
|
|
|
|
|
2019-12-02 09:12:26 -07:00
|
|
|
|
func Test_qfjump()
|
|
|
|
|
call Xqfjump_tests('c')
|
|
|
|
|
call Xqfjump_tests('l')
|
|
|
|
|
endfunc
|
2019-04-08 08:00:11 -07:00
|
|
|
|
|
2019-12-02 09:12:26 -07:00
|
|
|
|
" Tests for the getqflist() and getloclist() functions when the list is not
|
|
|
|
|
" present or is empty
|
|
|
|
|
func Xgetlist_empty_tests(cchar)
|
|
|
|
|
call s:setup_commands(a:cchar)
|
2019-04-19 09:54:56 -07:00
|
|
|
|
|
|
|
|
|
" Empty quickfix stack
|
|
|
|
|
call g:Xsetlist([], 'f')
|
|
|
|
|
call assert_equal('', g:Xgetlist({'context' : 0}).context)
|
|
|
|
|
call assert_equal(0, g:Xgetlist({'id' : 0}).id)
|
|
|
|
|
call assert_equal(0, g:Xgetlist({'idx' : 0}).idx)
|
|
|
|
|
call assert_equal([], g:Xgetlist({'items' : 0}).items)
|
|
|
|
|
call assert_equal(0, g:Xgetlist({'nr' : 0}).nr)
|
|
|
|
|
call assert_equal(0, g:Xgetlist({'size' : 0}).size)
|
|
|
|
|
call assert_equal('', g:Xgetlist({'title' : 0}).title)
|
|
|
|
|
call assert_equal(0, g:Xgetlist({'winid' : 0}).winid)
|
2019-04-19 04:13:24 -07:00
|
|
|
|
call assert_equal(0, g:Xgetlist({'changedtick' : 0}).changedtick)
|
2019-10-13 16:49:17 -07:00
|
|
|
|
if a:cchar == 'c'
|
|
|
|
|
call assert_equal({'context' : '', 'id' : 0, 'idx' : 0,
|
2020-10-10 12:42:25 -07:00
|
|
|
|
\ 'items' : [], 'nr' : 0, 'size' : 0, 'qfbufnr' : 0,
|
2021-06-22 19:02:59 -07:00
|
|
|
|
\ 'title' : '', 'winid' : 0, 'changedtick': 0,
|
|
|
|
|
\ 'quickfixtextfunc' : ''}, g:Xgetlist({'all' : 0}))
|
2019-10-13 16:49:17 -07:00
|
|
|
|
else
|
|
|
|
|
call assert_equal({'context' : '', 'id' : 0, 'idx' : 0,
|
|
|
|
|
\ 'items' : [], 'nr' : 0, 'size' : 0, 'title' : '',
|
2021-06-22 19:02:59 -07:00
|
|
|
|
\ 'winid' : 0, 'changedtick': 0, 'filewinid' : 0,
|
2020-10-10 12:42:25 -07:00
|
|
|
|
\ 'qfbufnr' : 0, 'quickfixtextfunc' : ''},
|
2019-10-13 16:49:17 -07:00
|
|
|
|
\ g:Xgetlist({'all' : 0}))
|
|
|
|
|
endif
|
2019-04-19 09:54:56 -07:00
|
|
|
|
|
2019-05-03 08:32:01 -07:00
|
|
|
|
" Quickfix window with empty stack
|
|
|
|
|
silent! Xopen
|
|
|
|
|
let qfwinid = (a:cchar == 'c') ? win_getid() : 0
|
2020-10-10 12:42:25 -07:00
|
|
|
|
let qfbufnr = (a:cchar == 'c') ? bufnr('') : 0
|
2019-05-03 08:32:01 -07:00
|
|
|
|
call assert_equal(qfwinid, g:Xgetlist({'winid' : 0}).winid)
|
|
|
|
|
Xclose
|
|
|
|
|
|
2019-04-19 09:54:56 -07:00
|
|
|
|
" Empty quickfix list
|
|
|
|
|
Xexpr ""
|
|
|
|
|
call assert_equal('', g:Xgetlist({'context' : 0}).context)
|
|
|
|
|
call assert_notequal(0, g:Xgetlist({'id' : 0}).id)
|
|
|
|
|
call assert_equal(0, g:Xgetlist({'idx' : 0}).idx)
|
|
|
|
|
call assert_equal([], g:Xgetlist({'items' : 0}).items)
|
|
|
|
|
call assert_notequal(0, g:Xgetlist({'nr' : 0}).nr)
|
|
|
|
|
call assert_equal(0, g:Xgetlist({'size' : 0}).size)
|
|
|
|
|
call assert_notequal('', g:Xgetlist({'title' : 0}).title)
|
|
|
|
|
call assert_equal(0, g:Xgetlist({'winid' : 0}).winid)
|
2019-04-19 04:13:24 -07:00
|
|
|
|
call assert_equal(1, g:Xgetlist({'changedtick' : 0}).changedtick)
|
2019-04-19 09:54:56 -07:00
|
|
|
|
|
|
|
|
|
let qfid = g:Xgetlist({'id' : 0}).id
|
|
|
|
|
call g:Xsetlist([], 'f')
|
|
|
|
|
|
|
|
|
|
" Non-existing quickfix identifier
|
|
|
|
|
call assert_equal('', g:Xgetlist({'id' : qfid, 'context' : 0}).context)
|
|
|
|
|
call assert_equal(0, g:Xgetlist({'id' : qfid}).id)
|
|
|
|
|
call assert_equal(0, g:Xgetlist({'id' : qfid, 'idx' : 0}).idx)
|
|
|
|
|
call assert_equal([], g:Xgetlist({'id' : qfid, 'items' : 0}).items)
|
|
|
|
|
call assert_equal(0, g:Xgetlist({'id' : qfid, 'nr' : 0}).nr)
|
|
|
|
|
call assert_equal(0, g:Xgetlist({'id' : qfid, 'size' : 0}).size)
|
|
|
|
|
call assert_equal('', g:Xgetlist({'id' : qfid, 'title' : 0}).title)
|
|
|
|
|
call assert_equal(0, g:Xgetlist({'id' : qfid, 'winid' : 0}).winid)
|
2019-04-19 04:13:24 -07:00
|
|
|
|
call assert_equal(0, g:Xgetlist({'id' : qfid, 'changedtick' : 0}).changedtick)
|
2019-10-13 16:49:17 -07:00
|
|
|
|
if a:cchar == 'c'
|
|
|
|
|
call assert_equal({'context' : '', 'id' : 0, 'idx' : 0, 'items' : [],
|
|
|
|
|
\ 'nr' : 0, 'size' : 0, 'title' : '', 'winid' : 0,
|
2020-10-10 12:42:25 -07:00
|
|
|
|
\ 'qfbufnr' : qfbufnr, 'quickfixtextfunc' : '',
|
2019-10-13 16:49:17 -07:00
|
|
|
|
\ 'changedtick' : 0}, g:Xgetlist({'id' : qfid, 'all' : 0}))
|
|
|
|
|
else
|
|
|
|
|
call assert_equal({'context' : '', 'id' : 0, 'idx' : 0, 'items' : [],
|
|
|
|
|
\ 'nr' : 0, 'size' : 0, 'title' : '', 'winid' : 0,
|
2020-10-10 12:42:25 -07:00
|
|
|
|
\ 'changedtick' : 0, 'filewinid' : 0, 'qfbufnr' : 0,
|
2021-06-22 19:02:59 -07:00
|
|
|
|
\ 'quickfixtextfunc' : ''},
|
2019-10-13 16:49:17 -07:00
|
|
|
|
\ g:Xgetlist({'id' : qfid, 'all' : 0}))
|
|
|
|
|
endif
|
2019-04-19 09:54:56 -07:00
|
|
|
|
|
|
|
|
|
" Non-existing quickfix list number
|
|
|
|
|
call assert_equal('', g:Xgetlist({'nr' : 5, 'context' : 0}).context)
|
|
|
|
|
call assert_equal(0, g:Xgetlist({'nr' : 5}).nr)
|
|
|
|
|
call assert_equal(0, g:Xgetlist({'nr' : 5, 'idx' : 0}).idx)
|
|
|
|
|
call assert_equal([], g:Xgetlist({'nr' : 5, 'items' : 0}).items)
|
|
|
|
|
call assert_equal(0, g:Xgetlist({'nr' : 5, 'id' : 0}).id)
|
|
|
|
|
call assert_equal(0, g:Xgetlist({'nr' : 5, 'size' : 0}).size)
|
|
|
|
|
call assert_equal('', g:Xgetlist({'nr' : 5, 'title' : 0}).title)
|
|
|
|
|
call assert_equal(0, g:Xgetlist({'nr' : 5, 'winid' : 0}).winid)
|
2019-04-19 04:13:24 -07:00
|
|
|
|
call assert_equal(0, g:Xgetlist({'nr' : 5, 'changedtick' : 0}).changedtick)
|
2019-10-13 16:49:17 -07:00
|
|
|
|
if a:cchar == 'c'
|
|
|
|
|
call assert_equal({'context' : '', 'id' : 0, 'idx' : 0, 'items' : [],
|
|
|
|
|
\ 'nr' : 0, 'size' : 0, 'title' : '', 'winid' : 0,
|
2020-10-10 12:42:25 -07:00
|
|
|
|
\ 'changedtick' : 0, 'qfbufnr' : qfbufnr,
|
2021-06-22 19:02:59 -07:00
|
|
|
|
\ 'quickfixtextfunc' : ''}, g:Xgetlist({'nr' : 5, 'all' : 0}))
|
2019-10-13 16:49:17 -07:00
|
|
|
|
else
|
|
|
|
|
call assert_equal({'context' : '', 'id' : 0, 'idx' : 0, 'items' : [],
|
|
|
|
|
\ 'nr' : 0, 'size' : 0, 'title' : '', 'winid' : 0,
|
2020-10-10 12:42:25 -07:00
|
|
|
|
\ 'changedtick' : 0, 'filewinid' : 0, 'qfbufnr' : 0,
|
2021-06-22 19:02:59 -07:00
|
|
|
|
\ 'quickfixtextfunc' : ''}, g:Xgetlist({'nr' : 5, 'all' : 0}))
|
2019-10-13 16:49:17 -07:00
|
|
|
|
endif
|
2019-04-19 09:54:56 -07:00
|
|
|
|
endfunc
|
|
|
|
|
|
2022-12-02 22:34:25 -07:00
|
|
|
|
func Test_empty_list_quickfixtextfunc()
|
|
|
|
|
" This was crashing. Can only reproduce by running it in a separate Vim
|
|
|
|
|
" instance.
|
|
|
|
|
let lines =<< trim END
|
|
|
|
|
func s:Func(o)
|
|
|
|
|
cgetexpr '0'
|
|
|
|
|
endfunc
|
|
|
|
|
cope
|
|
|
|
|
let &quickfixtextfunc = 's:Func'
|
|
|
|
|
cgetfile [ex
|
|
|
|
|
END
|
|
|
|
|
call writefile(lines, 'Xquickfixtextfunc')
|
|
|
|
|
call RunVim([], [], '-e -s -S Xquickfixtextfunc -c qa')
|
|
|
|
|
call delete('Xquickfixtextfunc')
|
|
|
|
|
endfunc
|
|
|
|
|
|
2019-04-19 09:54:56 -07:00
|
|
|
|
func Test_getqflist()
|
|
|
|
|
call Xgetlist_empty_tests('c')
|
|
|
|
|
call Xgetlist_empty_tests('l')
|
|
|
|
|
endfunc
|
2019-04-19 04:13:24 -07:00
|
|
|
|
|
2019-12-02 09:12:26 -07:00
|
|
|
|
|
|
|
|
|
func Test_getqflist_invalid_nr()
|
|
|
|
|
" The following commands used to crash Vim
|
|
|
|
|
cexpr ""
|
|
|
|
|
call getqflist({'nr' : $XXX_DOES_NOT_EXIST_XXX})
|
|
|
|
|
|
|
|
|
|
" Cleanup
|
|
|
|
|
call setqflist([], 'r')
|
|
|
|
|
endfunc
|
|
|
|
|
|
2019-04-19 04:13:24 -07:00
|
|
|
|
" Tests for the quickfix/location list changedtick
|
|
|
|
|
func Xqftick_tests(cchar)
|
|
|
|
|
call s:setup_commands(a:cchar)
|
|
|
|
|
|
|
|
|
|
call g:Xsetlist([], 'f')
|
|
|
|
|
|
|
|
|
|
Xexpr "F1:10:Line10"
|
|
|
|
|
let qfid = g:Xgetlist({'id' : 0}).id
|
|
|
|
|
call assert_equal(1, g:Xgetlist({'changedtick' : 0}).changedtick)
|
|
|
|
|
Xaddexpr "F2:20:Line20\nF2:21:Line21"
|
|
|
|
|
call assert_equal(2, g:Xgetlist({'changedtick' : 0}).changedtick)
|
|
|
|
|
call g:Xsetlist([], 'a', {'lines' : ["F3:30:Line30", "F3:31:Line31"]})
|
|
|
|
|
call assert_equal(3, g:Xgetlist({'changedtick' : 0}).changedtick)
|
|
|
|
|
call g:Xsetlist([], 'r', {'lines' : ["F4:40:Line40"]})
|
|
|
|
|
call assert_equal(4, g:Xgetlist({'changedtick' : 0}).changedtick)
|
|
|
|
|
call g:Xsetlist([], 'a', {'title' : 'New Title'})
|
|
|
|
|
call assert_equal(5, g:Xgetlist({'changedtick' : 0}).changedtick)
|
|
|
|
|
|
|
|
|
|
enew!
|
|
|
|
|
call append(0, ["F5:50:L50", "F6:60:L60"])
|
|
|
|
|
Xaddbuffer
|
|
|
|
|
call assert_equal(6, g:Xgetlist({'changedtick' : 0}).changedtick)
|
|
|
|
|
enew!
|
|
|
|
|
|
|
|
|
|
call g:Xsetlist([], 'a', {'context' : {'bus' : 'pci'}})
|
|
|
|
|
call assert_equal(7, g:Xgetlist({'changedtick' : 0}).changedtick)
|
|
|
|
|
call g:Xsetlist([{'filename' : 'F7', 'lnum' : 10, 'text' : 'L7'},
|
|
|
|
|
\ {'filename' : 'F7', 'lnum' : 11, 'text' : 'L11'}], 'a')
|
|
|
|
|
call assert_equal(8, g:Xgetlist({'changedtick' : 0}).changedtick)
|
|
|
|
|
call g:Xsetlist([{'filename' : 'F7', 'lnum' : 10, 'text' : 'L7'},
|
|
|
|
|
\ {'filename' : 'F7', 'lnum' : 11, 'text' : 'L11'}], ' ')
|
|
|
|
|
call assert_equal(1, g:Xgetlist({'changedtick' : 0}).changedtick)
|
|
|
|
|
call g:Xsetlist([{'filename' : 'F7', 'lnum' : 10, 'text' : 'L7'},
|
|
|
|
|
\ {'filename' : 'F7', 'lnum' : 11, 'text' : 'L11'}], 'r')
|
|
|
|
|
call assert_equal(2, g:Xgetlist({'changedtick' : 0}).changedtick)
|
|
|
|
|
|
2021-05-14 05:54:52 -07:00
|
|
|
|
if isdirectory("Xone")
|
|
|
|
|
call delete("Xone", 'rf')
|
|
|
|
|
endif
|
2019-04-19 04:13:24 -07:00
|
|
|
|
call writefile(["F8:80:L80", "F8:81:L81"], "Xone")
|
|
|
|
|
Xfile Xone
|
|
|
|
|
call assert_equal(1, g:Xgetlist({'changedtick' : 0}).changedtick)
|
|
|
|
|
Xaddfile Xone
|
|
|
|
|
call assert_equal(2, g:Xgetlist({'changedtick' : 0}).changedtick)
|
|
|
|
|
|
|
|
|
|
" Test case for updating a non-current quickfix list
|
|
|
|
|
call g:Xsetlist([], 'f')
|
|
|
|
|
Xexpr "F1:1:L1"
|
|
|
|
|
Xexpr "F2:2:L2"
|
|
|
|
|
call g:Xsetlist([], 'a', {'nr' : 1, "lines" : ["F10:10:L10"]})
|
|
|
|
|
call assert_equal(1, g:Xgetlist({'changedtick' : 0}).changedtick)
|
|
|
|
|
call assert_equal(2, g:Xgetlist({'nr' : 1, 'changedtick' : 0}).changedtick)
|
|
|
|
|
|
|
|
|
|
call delete("Xone")
|
|
|
|
|
endfunc
|
|
|
|
|
|
|
|
|
|
func Test_qf_tick()
|
|
|
|
|
call Xqftick_tests('c')
|
|
|
|
|
call Xqftick_tests('l')
|
|
|
|
|
endfunc
|
2019-04-08 10:31:25 -07:00
|
|
|
|
|
2019-12-02 09:12:26 -07:00
|
|
|
|
" Test helpgrep with lang specifier
|
|
|
|
|
func Xtest_helpgrep_with_lang_specifier(cchar)
|
|
|
|
|
call s:setup_commands(a:cchar)
|
|
|
|
|
Xhelpgrep Vim@en
|
|
|
|
|
call assert_equal('help', &filetype)
|
|
|
|
|
call assert_notequal(0, g:Xgetlist({'nr' : '$'}).nr)
|
|
|
|
|
new | only
|
|
|
|
|
endfunc
|
|
|
|
|
|
|
|
|
|
func Test_helpgrep_with_lang_specifier()
|
|
|
|
|
call Xtest_helpgrep_with_lang_specifier('c')
|
|
|
|
|
call Xtest_helpgrep_with_lang_specifier('l')
|
|
|
|
|
endfunc
|
|
|
|
|
|
|
|
|
|
" The following test used to crash Vim.
|
|
|
|
|
" Open the location list window and close the regular window associated with
|
|
|
|
|
" the location list. When the garbage collection runs now, it incorrectly
|
|
|
|
|
" marks the location list context as not in use and frees the context.
|
|
|
|
|
func Test_ll_window_ctx()
|
|
|
|
|
call setloclist(0, [], 'f')
|
|
|
|
|
call setloclist(0, [], 'a', {'context' : []})
|
|
|
|
|
lopen | only
|
|
|
|
|
call test_garbagecollect_now()
|
|
|
|
|
echo getloclist(0, {'context' : 1}).context
|
|
|
|
|
enew | only
|
|
|
|
|
endfunc
|
|
|
|
|
|
|
|
|
|
" The following test used to crash vim
|
|
|
|
|
func Test_lfile_crash()
|
|
|
|
|
sp Xtest
|
|
|
|
|
au QuickFixCmdPre * bw
|
|
|
|
|
call assert_fails('lfile', 'E40')
|
|
|
|
|
au! QuickFixCmdPre
|
|
|
|
|
endfunc
|
|
|
|
|
|
2019-04-08 10:31:25 -07:00
|
|
|
|
" The following test used to crash vim
|
|
|
|
|
func Test_lbuffer_crash()
|
|
|
|
|
sv Xtest
|
|
|
|
|
augroup QF_Test
|
|
|
|
|
au!
|
2021-01-28 21:06:30 -07:00
|
|
|
|
au QuickFixCmdPre,QuickFixCmdPost,BufEnter,BufLeave * bw
|
2019-04-08 10:31:25 -07:00
|
|
|
|
augroup END
|
|
|
|
|
lbuffer
|
|
|
|
|
augroup QF_Test
|
|
|
|
|
au!
|
|
|
|
|
augroup END
|
|
|
|
|
endfunc
|
|
|
|
|
|
|
|
|
|
" The following test used to crash vim
|
|
|
|
|
func Test_lexpr_crash()
|
|
|
|
|
augroup QF_Test
|
|
|
|
|
au!
|
2021-01-28 21:06:30 -07:00
|
|
|
|
au QuickFixCmdPre,QuickFixCmdPost,BufEnter,BufLeave * call setloclist(0, [], 'f')
|
2019-04-08 10:31:25 -07:00
|
|
|
|
augroup END
|
|
|
|
|
lexpr ""
|
|
|
|
|
augroup QF_Test
|
|
|
|
|
au!
|
|
|
|
|
augroup END
|
2019-10-27 13:17:35 -07:00
|
|
|
|
|
|
|
|
|
enew | only
|
|
|
|
|
augroup QF_Test
|
|
|
|
|
au!
|
|
|
|
|
au BufNew * call setloclist(0, [], 'f')
|
|
|
|
|
augroup END
|
|
|
|
|
lexpr 'x:1:x'
|
|
|
|
|
augroup QF_Test
|
|
|
|
|
au!
|
|
|
|
|
augroup END
|
|
|
|
|
|
2019-04-08 10:31:25 -07:00
|
|
|
|
enew | only
|
2019-10-27 13:17:35 -07:00
|
|
|
|
lexpr ''
|
|
|
|
|
lopen
|
|
|
|
|
augroup QF_Test
|
|
|
|
|
au!
|
|
|
|
|
au FileType * call setloclist(0, [], 'f')
|
|
|
|
|
augroup END
|
|
|
|
|
lexpr ''
|
|
|
|
|
augroup QF_Test
|
|
|
|
|
au!
|
|
|
|
|
augroup END
|
2019-04-08 10:31:25 -07:00
|
|
|
|
endfunc
|
|
|
|
|
|
|
|
|
|
" The following test used to crash Vim
|
|
|
|
|
func Test_lvimgrep_crash()
|
|
|
|
|
sv Xtest
|
|
|
|
|
augroup QF_Test
|
|
|
|
|
au!
|
2021-01-28 21:06:30 -07:00
|
|
|
|
au QuickFixCmdPre,QuickFixCmdPost,BufEnter,BufLeave * call setloclist(0, [], 'f')
|
2019-04-08 10:31:25 -07:00
|
|
|
|
augroup END
|
|
|
|
|
lvimgrep quickfix test_quickfix.vim
|
|
|
|
|
augroup QF_Test
|
|
|
|
|
au!
|
|
|
|
|
augroup END
|
2020-09-12 09:39:07 -07:00
|
|
|
|
|
|
|
|
|
new | only
|
|
|
|
|
augroup QF_Test
|
|
|
|
|
au!
|
|
|
|
|
au BufEnter * call setloclist(0, [], 'r')
|
|
|
|
|
augroup END
|
|
|
|
|
call assert_fails('lvimgrep Test_lvimgrep_crash *', 'E926:')
|
|
|
|
|
augroup QF_Test
|
|
|
|
|
au!
|
|
|
|
|
augroup END
|
|
|
|
|
|
2019-04-08 10:31:25 -07:00
|
|
|
|
enew | only
|
|
|
|
|
endfunc
|
2019-06-05 19:52:38 -07:00
|
|
|
|
|
2020-03-14 10:41:42 -07:00
|
|
|
|
func Test_lvimgrep_crash2()
|
|
|
|
|
au BufNewFile x sfind
|
2022-11-04 16:24:06 -07:00
|
|
|
|
call assert_fails('lvimgrep x x', 'E471:')
|
|
|
|
|
call assert_fails('lvimgrep x x x', 'E471:')
|
2020-03-14 10:41:42 -07:00
|
|
|
|
|
|
|
|
|
au! BufNewFile
|
|
|
|
|
endfunc
|
|
|
|
|
|
2019-12-02 09:12:26 -07:00
|
|
|
|
" Test for the position of the quickfix and location list window
|
|
|
|
|
func Test_qfwin_pos()
|
|
|
|
|
" Open two windows
|
|
|
|
|
new | only
|
|
|
|
|
new
|
|
|
|
|
cexpr ['F1:10:L10']
|
|
|
|
|
copen
|
|
|
|
|
" Quickfix window should be the bottom most window
|
|
|
|
|
call assert_equal(3, winnr())
|
|
|
|
|
close
|
|
|
|
|
" Open at the very top
|
|
|
|
|
wincmd t
|
|
|
|
|
topleft copen
|
|
|
|
|
call assert_equal(1, winnr())
|
|
|
|
|
close
|
|
|
|
|
" open left of the current window
|
|
|
|
|
wincmd t
|
|
|
|
|
below new
|
|
|
|
|
leftabove copen
|
|
|
|
|
call assert_equal(2, winnr())
|
|
|
|
|
close
|
|
|
|
|
" open right of the current window
|
|
|
|
|
rightbelow copen
|
|
|
|
|
call assert_equal(3, winnr())
|
|
|
|
|
close
|
|
|
|
|
endfunc
|
2019-06-05 19:52:38 -07:00
|
|
|
|
|
2019-12-02 09:12:26 -07:00
|
|
|
|
" Tests for quickfix/location lists changed by autocommands when
|
|
|
|
|
" :vimgrep/:lvimgrep commands are running.
|
|
|
|
|
func Test_vimgrep_autocmd()
|
|
|
|
|
call setqflist([], 'f')
|
|
|
|
|
call writefile(['stars'], 'Xtest1.txt')
|
|
|
|
|
call writefile(['stars'], 'Xtest2.txt')
|
2019-06-05 19:52:38 -07:00
|
|
|
|
|
2019-12-02 09:12:26 -07:00
|
|
|
|
" Test 1:
|
|
|
|
|
" When searching for a pattern using :vimgrep, if the quickfix list is
|
|
|
|
|
" changed by an autocmd, the results should be added to the correct quickfix
|
|
|
|
|
" list.
|
|
|
|
|
autocmd BufRead Xtest2.txt cexpr '' | cexpr ''
|
|
|
|
|
silent vimgrep stars Xtest*.txt
|
|
|
|
|
call assert_equal(1, getqflist({'nr' : 0}).nr)
|
|
|
|
|
call assert_equal(3, getqflist({'nr' : '$'}).nr)
|
|
|
|
|
call assert_equal('Xtest2.txt', bufname(getqflist()[1].bufnr))
|
|
|
|
|
au! BufRead Xtest2.txt
|
2019-06-05 19:52:38 -07:00
|
|
|
|
|
2019-12-02 09:12:26 -07:00
|
|
|
|
" Test 2:
|
|
|
|
|
" When searching for a pattern using :vimgrep, if the quickfix list is
|
|
|
|
|
" freed, then a error should be given.
|
|
|
|
|
silent! %bwipe!
|
|
|
|
|
call setqflist([], 'f')
|
|
|
|
|
autocmd BufRead Xtest2.txt for i in range(10) | cexpr '' | endfor
|
|
|
|
|
call assert_fails('vimgrep stars Xtest*.txt', 'E925:')
|
|
|
|
|
au! BufRead Xtest2.txt
|
2019-06-05 19:52:38 -07:00
|
|
|
|
|
2019-12-02 09:12:26 -07:00
|
|
|
|
" Test 3:
|
|
|
|
|
" When searching for a pattern using :lvimgrep, if the location list is
|
|
|
|
|
" freed, then the command should error out.
|
|
|
|
|
silent! %bwipe!
|
|
|
|
|
let g:save_winid = win_getid()
|
|
|
|
|
autocmd BufRead Xtest2.txt call setloclist(g:save_winid, [], 'f')
|
|
|
|
|
call assert_fails('lvimgrep stars Xtest*.txt', 'E926:')
|
|
|
|
|
au! BufRead Xtest2.txt
|
2019-06-05 19:52:38 -07:00
|
|
|
|
|
2019-12-02 09:12:26 -07:00
|
|
|
|
call delete('Xtest1.txt')
|
|
|
|
|
call delete('Xtest2.txt')
|
|
|
|
|
call setqflist([], 'f')
|
|
|
|
|
endfunc
|
2019-06-05 19:52:38 -07:00
|
|
|
|
|
2021-05-20 15:05:39 -07:00
|
|
|
|
" Test for an autocmd changing the current directory when running vimgrep
|
|
|
|
|
func Xvimgrep_autocmd_cd(cchar)
|
|
|
|
|
call s:setup_commands(a:cchar)
|
|
|
|
|
|
|
|
|
|
%bwipe
|
|
|
|
|
let save_cwd = getcwd()
|
|
|
|
|
|
|
|
|
|
augroup QF_Test
|
|
|
|
|
au!
|
|
|
|
|
autocmd BufRead * silent cd %:p:h
|
|
|
|
|
augroup END
|
|
|
|
|
|
|
|
|
|
10Xvimgrep /vim/ Xdir/**
|
|
|
|
|
let l = g:Xgetlist()
|
|
|
|
|
call assert_equal('f1.txt', bufname(l[0].bufnr))
|
|
|
|
|
call assert_equal('f2.txt', fnamemodify(bufname(l[2].bufnr), ':t'))
|
|
|
|
|
|
|
|
|
|
augroup QF_Test
|
|
|
|
|
au!
|
|
|
|
|
augroup END
|
|
|
|
|
|
|
|
|
|
exe 'cd ' . save_cwd
|
|
|
|
|
endfunc
|
|
|
|
|
|
|
|
|
|
func Test_vimgrep_autocmd_cd()
|
|
|
|
|
call mkdir('Xdir/a', 'p')
|
|
|
|
|
call mkdir('Xdir/b', 'p')
|
|
|
|
|
call writefile(['a_L1_vim', 'a_L2_vim'], 'Xdir/a/f1.txt')
|
|
|
|
|
call writefile(['b_L1_vim', 'b_L2_vim'], 'Xdir/b/f2.txt')
|
|
|
|
|
call Xvimgrep_autocmd_cd('c')
|
|
|
|
|
call Xvimgrep_autocmd_cd('l')
|
|
|
|
|
%bwipe
|
|
|
|
|
call delete('Xdir', 'rf')
|
|
|
|
|
endfunc
|
|
|
|
|
|
2019-12-02 09:12:26 -07:00
|
|
|
|
" The following test used to crash Vim
|
|
|
|
|
func Test_lhelpgrep_autocmd()
|
|
|
|
|
lhelpgrep quickfix
|
2022-10-12 19:13:17 -07:00
|
|
|
|
augroup QF_Test
|
|
|
|
|
au!
|
|
|
|
|
autocmd QuickFixCmdPost * call setloclist(0, [], 'f')
|
|
|
|
|
augroup END
|
2019-12-02 09:12:26 -07:00
|
|
|
|
lhelpgrep buffer
|
|
|
|
|
call assert_equal('help', &filetype)
|
|
|
|
|
call assert_equal(0, getloclist(0, {'nr' : '$'}).nr)
|
|
|
|
|
lhelpgrep tabpage
|
|
|
|
|
call assert_equal('help', &filetype)
|
|
|
|
|
call assert_equal(1, getloclist(0, {'nr' : '$'}).nr)
|
2022-10-12 19:13:17 -07:00
|
|
|
|
augroup QF_Test
|
|
|
|
|
au!
|
|
|
|
|
augroup END
|
2020-09-12 09:39:07 -07:00
|
|
|
|
|
|
|
|
|
new | only
|
|
|
|
|
augroup QF_Test
|
|
|
|
|
au!
|
|
|
|
|
au BufEnter * call setqflist([], 'f')
|
|
|
|
|
augroup END
|
|
|
|
|
call assert_fails('helpgrep quickfix', 'E925:')
|
2020-11-02 19:57:29 -07:00
|
|
|
|
" run the test with a help window already open
|
|
|
|
|
help
|
|
|
|
|
wincmd w
|
|
|
|
|
call assert_fails('helpgrep quickfix', 'E925:')
|
2020-09-12 09:39:07 -07:00
|
|
|
|
augroup QF_Test
|
2022-10-12 19:13:17 -07:00
|
|
|
|
au!
|
2020-09-12 09:39:07 -07:00
|
|
|
|
augroup END
|
|
|
|
|
|
|
|
|
|
new | only
|
|
|
|
|
augroup QF_Test
|
|
|
|
|
au!
|
|
|
|
|
au BufEnter * call setqflist([], 'r')
|
|
|
|
|
augroup END
|
|
|
|
|
call assert_fails('helpgrep quickfix', 'E925:')
|
|
|
|
|
augroup QF_Test
|
2022-10-12 19:13:17 -07:00
|
|
|
|
au!
|
2020-09-12 09:39:07 -07:00
|
|
|
|
augroup END
|
|
|
|
|
|
|
|
|
|
new | only
|
|
|
|
|
augroup QF_Test
|
|
|
|
|
au!
|
|
|
|
|
au BufEnter * call setloclist(0, [], 'r')
|
|
|
|
|
augroup END
|
|
|
|
|
call assert_fails('lhelpgrep quickfix', 'E926:')
|
|
|
|
|
augroup QF_Test
|
2022-10-12 19:13:17 -07:00
|
|
|
|
au!
|
2020-09-12 09:39:07 -07:00
|
|
|
|
augroup END
|
|
|
|
|
|
2022-10-12 19:13:17 -07:00
|
|
|
|
" Replace the contents of a help window location list when it is still in
|
|
|
|
|
" use.
|
2019-06-05 19:52:38 -07:00
|
|
|
|
new | only
|
2022-10-12 19:13:17 -07:00
|
|
|
|
lhelpgrep quickfix
|
|
|
|
|
wincmd w
|
|
|
|
|
augroup QF_Test
|
|
|
|
|
au!
|
|
|
|
|
autocmd WinEnter * call setloclist(0, [], 'r')
|
|
|
|
|
augroup END
|
|
|
|
|
call assert_fails('lhelpgrep win_getid', 'E926:')
|
|
|
|
|
augroup QF_Test
|
|
|
|
|
au!
|
|
|
|
|
augroup END
|
|
|
|
|
|
|
|
|
|
%bw!
|
|
|
|
|
endfunc
|
|
|
|
|
|
|
|
|
|
" The following test used to crash Vim
|
|
|
|
|
func Test_lhelpgrep_autocmd_free_loclist()
|
|
|
|
|
%bw!
|
|
|
|
|
lhelpgrep quickfix
|
|
|
|
|
wincmd w
|
|
|
|
|
augroup QF_Test
|
|
|
|
|
au!
|
|
|
|
|
autocmd WinEnter * call setloclist(0, [], 'f')
|
|
|
|
|
augroup END
|
|
|
|
|
lhelpgrep win_getid
|
|
|
|
|
wincmd w
|
|
|
|
|
wincmd w
|
|
|
|
|
wincmd w
|
|
|
|
|
augroup QF_Test
|
|
|
|
|
au!
|
|
|
|
|
augroup END
|
|
|
|
|
%bw!
|
2019-12-02 09:12:26 -07:00
|
|
|
|
endfunc
|
2019-06-05 19:52:38 -07:00
|
|
|
|
|
2019-12-02 09:12:26 -07:00
|
|
|
|
" Test for shortening/simplifying the file name when opening the
|
|
|
|
|
" quickfix window or when displaying the quickfix list
|
|
|
|
|
func Test_shorten_fname()
|
|
|
|
|
if !has('unix')
|
|
|
|
|
return
|
|
|
|
|
endif
|
|
|
|
|
%bwipe
|
|
|
|
|
" Create a quickfix list with a absolute path filename
|
|
|
|
|
let fname = getcwd() . '/test_quickfix.vim'
|
|
|
|
|
call setqflist([], ' ', {'lines':[fname . ":20:Line20"], 'efm':'%f:%l:%m'})
|
|
|
|
|
call assert_equal(fname, bufname('test_quickfix.vim'))
|
|
|
|
|
" Opening the quickfix window should simplify the file path
|
|
|
|
|
cwindow
|
|
|
|
|
call assert_equal('test_quickfix.vim', bufname('test_quickfix.vim'))
|
|
|
|
|
cclose
|
|
|
|
|
%bwipe
|
|
|
|
|
" Create a quickfix list with a absolute path filename
|
|
|
|
|
call setqflist([], ' ', {'lines':[fname . ":20:Line20"], 'efm':'%f:%l:%m'})
|
|
|
|
|
call assert_equal(fname, bufname('test_quickfix.vim'))
|
|
|
|
|
" Displaying the quickfix list should simplify the file path
|
|
|
|
|
silent! clist
|
|
|
|
|
call assert_equal('test_quickfix.vim', bufname('test_quickfix.vim'))
|
2020-09-30 17:58:36 -07:00
|
|
|
|
" Add a few entries for the same file with different paths and check whether
|
|
|
|
|
" the buffer name is shortened
|
|
|
|
|
%bwipe
|
|
|
|
|
call setqflist([], 'f')
|
|
|
|
|
call setqflist([{'filename' : 'test_quickfix.vim', 'lnum' : 10},
|
|
|
|
|
\ {'filename' : '../testdir/test_quickfix.vim', 'lnum' : 20},
|
|
|
|
|
\ {'filename' : fname, 'lnum' : 30}], ' ')
|
|
|
|
|
copen
|
|
|
|
|
call assert_equal(['test_quickfix.vim|10| ',
|
|
|
|
|
\ 'test_quickfix.vim|20| ',
|
|
|
|
|
\ 'test_quickfix.vim|30| '], getline(1, '$'))
|
|
|
|
|
cclose
|
2019-06-05 19:52:38 -07:00
|
|
|
|
endfunc
|
|
|
|
|
|
2019-12-02 09:12:26 -07:00
|
|
|
|
" Quickfix title tests
|
|
|
|
|
" In the below tests, 'exe "cmd"' is used to invoke the quickfix commands.
|
|
|
|
|
" Otherwise due to indentation, the title is set with spaces at the beginning
|
|
|
|
|
" of the command.
|
|
|
|
|
func Test_qftitle()
|
|
|
|
|
call writefile(["F1:1:Line1"], 'Xerr')
|
|
|
|
|
|
|
|
|
|
" :cexpr
|
|
|
|
|
exe "cexpr readfile('Xerr')"
|
|
|
|
|
call assert_equal(":cexpr readfile('Xerr')", getqflist({'title' : 1}).title)
|
|
|
|
|
|
|
|
|
|
" :cgetexpr
|
|
|
|
|
exe "cgetexpr readfile('Xerr')"
|
|
|
|
|
call assert_equal(":cgetexpr readfile('Xerr')",
|
|
|
|
|
\ getqflist({'title' : 1}).title)
|
|
|
|
|
|
|
|
|
|
" :caddexpr
|
|
|
|
|
call setqflist([], 'f')
|
|
|
|
|
exe "caddexpr readfile('Xerr')"
|
|
|
|
|
call assert_equal(":caddexpr readfile('Xerr')",
|
|
|
|
|
\ getqflist({'title' : 1}).title)
|
|
|
|
|
|
|
|
|
|
" :cbuffer
|
|
|
|
|
new Xerr
|
|
|
|
|
exe "cbuffer"
|
|
|
|
|
call assert_equal(':cbuffer (Xerr)', getqflist({'title' : 1}).title)
|
|
|
|
|
|
|
|
|
|
" :cgetbuffer
|
|
|
|
|
edit Xerr
|
|
|
|
|
exe "cgetbuffer"
|
|
|
|
|
call assert_equal(':cgetbuffer (Xerr)', getqflist({'title' : 1}).title)
|
2019-06-05 20:12:20 -07:00
|
|
|
|
|
2019-12-02 09:12:26 -07:00
|
|
|
|
" :caddbuffer
|
|
|
|
|
call setqflist([], 'f')
|
|
|
|
|
edit Xerr
|
|
|
|
|
exe "caddbuffer"
|
|
|
|
|
call assert_equal(':caddbuffer (Xerr)', getqflist({'title' : 1}).title)
|
2019-09-30 19:58:42 -07:00
|
|
|
|
|
2019-12-02 09:12:26 -07:00
|
|
|
|
" :cfile
|
|
|
|
|
exe "cfile Xerr"
|
|
|
|
|
call assert_equal(':cfile Xerr', getqflist({'title' : 1}).title)
|
2019-09-30 19:58:42 -07:00
|
|
|
|
|
2019-12-02 09:12:26 -07:00
|
|
|
|
" :cgetfile
|
|
|
|
|
exe "cgetfile Xerr"
|
|
|
|
|
call assert_equal(':cgetfile Xerr', getqflist({'title' : 1}).title)
|
2019-06-05 20:12:20 -07:00
|
|
|
|
|
2019-12-02 09:12:26 -07:00
|
|
|
|
" :caddfile
|
|
|
|
|
call setqflist([], 'f')
|
|
|
|
|
exe "caddfile Xerr"
|
|
|
|
|
call assert_equal(':caddfile Xerr', getqflist({'title' : 1}).title)
|
2019-06-06 01:52:06 -07:00
|
|
|
|
|
2019-12-02 09:12:26 -07:00
|
|
|
|
" :grep
|
|
|
|
|
set grepprg=internal
|
|
|
|
|
exe "grep F1 Xerr"
|
|
|
|
|
call assert_equal(':grep F1 Xerr', getqflist({'title' : 1}).title)
|
|
|
|
|
|
|
|
|
|
" :grepadd
|
2019-06-06 01:52:06 -07:00
|
|
|
|
call setqflist([], 'f')
|
2019-12-02 09:12:26 -07:00
|
|
|
|
exe "grepadd F1 Xerr"
|
|
|
|
|
call assert_equal(':grepadd F1 Xerr', getqflist({'title' : 1}).title)
|
|
|
|
|
set grepprg&vim
|
2019-06-06 01:52:06 -07:00
|
|
|
|
|
2019-12-02 09:12:26 -07:00
|
|
|
|
" :vimgrep
|
|
|
|
|
exe "vimgrep F1 Xerr"
|
|
|
|
|
call assert_equal(':vimgrep F1 Xerr', getqflist({'title' : 1}).title)
|
2019-06-06 01:52:06 -07:00
|
|
|
|
|
2019-12-02 09:12:26 -07:00
|
|
|
|
" :vimgrepadd
|
2019-06-06 01:52:06 -07:00
|
|
|
|
call setqflist([], 'f')
|
2019-12-02 09:12:26 -07:00
|
|
|
|
exe "vimgrepadd F1 Xerr"
|
|
|
|
|
call assert_equal(':vimgrepadd F1 Xerr', getqflist({'title' : 1}).title)
|
2019-06-06 01:52:06 -07:00
|
|
|
|
|
2019-12-02 09:12:26 -07:00
|
|
|
|
call setqflist(['F1:10:L10'], ' ')
|
|
|
|
|
call assert_equal(':setqflist()', getqflist({'title' : 1}).title)
|
2019-06-06 01:52:06 -07:00
|
|
|
|
|
|
|
|
|
call setqflist([], 'f')
|
2019-12-02 09:12:26 -07:00
|
|
|
|
call setqflist(['F1:10:L10'], 'a')
|
|
|
|
|
call assert_equal(':setqflist()', getqflist({'title' : 1}).title)
|
|
|
|
|
|
|
|
|
|
call setqflist([], 'f')
|
|
|
|
|
call setqflist(['F1:10:L10'], 'r')
|
|
|
|
|
call assert_equal(':setqflist()', getqflist({'title' : 1}).title)
|
|
|
|
|
|
|
|
|
|
close
|
|
|
|
|
call delete('Xerr')
|
|
|
|
|
|
|
|
|
|
call setqflist([], ' ', {'title' : 'Errors'})
|
|
|
|
|
copen
|
|
|
|
|
call assert_equal('Errors', w:quickfix_title)
|
|
|
|
|
call setqflist([], 'r', {'items' : [{'filename' : 'a.c', 'lnum' : 10}]})
|
|
|
|
|
call assert_equal('Errors', w:quickfix_title)
|
|
|
|
|
cclose
|
2020-12-17 07:14:19 -07:00
|
|
|
|
|
|
|
|
|
" Switching to another quickfix list in one tab page should update the
|
|
|
|
|
" quickfix window title and statusline in all the other tab pages also
|
|
|
|
|
call setqflist([], 'f')
|
|
|
|
|
%bw!
|
|
|
|
|
cgetexpr ['file_one:1:1: error in the first quickfix list']
|
|
|
|
|
call setqflist([], 'a', {'title': 'first quickfix list'})
|
|
|
|
|
cgetexpr ['file_two:2:1: error in the second quickfix list']
|
|
|
|
|
call setqflist([], 'a', {'title': 'second quickfix list'})
|
|
|
|
|
copen
|
|
|
|
|
wincmd t
|
|
|
|
|
tabnew two
|
|
|
|
|
copen
|
|
|
|
|
wincmd t
|
|
|
|
|
colder
|
|
|
|
|
call assert_equal('first quickfix list', gettabwinvar(1, 2, 'quickfix_title'))
|
|
|
|
|
call assert_equal('first quickfix list', gettabwinvar(2, 2, 'quickfix_title'))
|
|
|
|
|
call assert_equal(1, tabpagewinnr(1))
|
|
|
|
|
call assert_equal(1, tabpagewinnr(2))
|
|
|
|
|
tabnew
|
|
|
|
|
call setqflist([], 'a', {'title': 'new quickfix title'})
|
|
|
|
|
call assert_equal('new quickfix title', gettabwinvar(1, 2, 'quickfix_title'))
|
|
|
|
|
call assert_equal('new quickfix title', gettabwinvar(2, 2, 'quickfix_title'))
|
|
|
|
|
%bw!
|
2019-06-06 01:52:06 -07:00
|
|
|
|
endfunc
|
2019-06-06 16:59:17 -07:00
|
|
|
|
|
|
|
|
|
func Test_lbuffer_with_bwipe()
|
|
|
|
|
new
|
|
|
|
|
new
|
|
|
|
|
augroup nasty
|
2021-01-28 21:06:30 -07:00
|
|
|
|
au QuickFixCmdPre,QuickFixCmdPost,BufEnter,BufLeave * bwipe
|
2019-06-06 16:59:17 -07:00
|
|
|
|
augroup END
|
|
|
|
|
lbuffer
|
|
|
|
|
augroup nasty
|
|
|
|
|
au!
|
|
|
|
|
augroup END
|
|
|
|
|
endfunc
|
2019-06-11 20:16:16 -07:00
|
|
|
|
|
2019-09-01 08:46:07 -07:00
|
|
|
|
" Test for an autocmd freeing the quickfix/location list when cexpr/lexpr is
|
|
|
|
|
" running
|
|
|
|
|
func Xexpr_acmd_freelist(cchar)
|
|
|
|
|
call s:setup_commands(a:cchar)
|
|
|
|
|
|
2021-01-28 21:06:30 -07:00
|
|
|
|
" This was using freed memory (but with what events?)
|
2019-06-17 20:22:26 -07:00
|
|
|
|
augroup nasty
|
2021-01-28 21:06:30 -07:00
|
|
|
|
au QuickFixCmdPre,QuickFixCmdPost,BufEnter,BufLeave * call g:Xsetlist([], 'f')
|
2019-06-17 20:22:26 -07:00
|
|
|
|
augroup END
|
2019-09-01 08:46:07 -07:00
|
|
|
|
Xexpr "x"
|
2019-06-17 20:22:26 -07:00
|
|
|
|
augroup nasty
|
|
|
|
|
au!
|
|
|
|
|
augroup END
|
|
|
|
|
endfunc
|
|
|
|
|
|
2019-09-01 08:46:07 -07:00
|
|
|
|
func Test_cexpr_acmd_freelist()
|
|
|
|
|
call Xexpr_acmd_freelist('c')
|
|
|
|
|
call Xexpr_acmd_freelist('l')
|
|
|
|
|
endfunc
|
|
|
|
|
|
|
|
|
|
" Test for commands that create a new quickfix/location list and jump to the
|
|
|
|
|
" first error automatically.
|
|
|
|
|
func Xjumpto_first_error_test(cchar)
|
|
|
|
|
call s:setup_commands(a:cchar)
|
|
|
|
|
|
|
|
|
|
call s:create_test_file('Xtestfile1')
|
|
|
|
|
call s:create_test_file('Xtestfile2')
|
|
|
|
|
let l = ['Xtestfile1:2:Line2', 'Xtestfile2:4:Line4']
|
|
|
|
|
|
|
|
|
|
" Test for cexpr/lexpr
|
|
|
|
|
enew
|
|
|
|
|
Xexpr l
|
2022-07-16 18:10:25 -07:00
|
|
|
|
call assert_equal('Xtestfile1', @%)
|
2019-09-01 08:46:07 -07:00
|
|
|
|
call assert_equal(2, line('.'))
|
|
|
|
|
|
|
|
|
|
" Test for cfile/lfile
|
|
|
|
|
enew
|
|
|
|
|
call writefile(l, 'Xerr')
|
|
|
|
|
Xfile Xerr
|
2022-07-16 18:10:25 -07:00
|
|
|
|
call assert_equal('Xtestfile1', @%)
|
2019-09-01 08:46:07 -07:00
|
|
|
|
call assert_equal(2, line('.'))
|
|
|
|
|
|
|
|
|
|
" Test for cbuffer/lbuffer
|
|
|
|
|
edit Xerr
|
|
|
|
|
Xbuffer
|
2022-07-16 18:10:25 -07:00
|
|
|
|
call assert_equal('Xtestfile1', @%)
|
2019-09-01 08:46:07 -07:00
|
|
|
|
call assert_equal(2, line('.'))
|
|
|
|
|
|
|
|
|
|
call delete('Xerr')
|
|
|
|
|
call delete('Xtestfile1')
|
|
|
|
|
call delete('Xtestfile2')
|
|
|
|
|
endfunc
|
|
|
|
|
|
|
|
|
|
func Test_jumpto_first_error()
|
|
|
|
|
call Xjumpto_first_error_test('c')
|
|
|
|
|
call Xjumpto_first_error_test('l')
|
|
|
|
|
endfunc
|
|
|
|
|
|
|
|
|
|
" Test for a quickfix autocmd changing the quickfix/location list before
|
|
|
|
|
" jumping to the first error in the new list.
|
|
|
|
|
func Xautocmd_changelist(cchar)
|
|
|
|
|
call s:setup_commands(a:cchar)
|
|
|
|
|
|
|
|
|
|
" Test for cfile/lfile
|
|
|
|
|
call s:create_test_file('Xtestfile1')
|
|
|
|
|
call s:create_test_file('Xtestfile2')
|
|
|
|
|
Xexpr 'Xtestfile1:2:Line2'
|
|
|
|
|
autocmd QuickFixCmdPost * Xolder
|
|
|
|
|
call writefile(['Xtestfile2:4:Line4'], 'Xerr')
|
|
|
|
|
Xfile Xerr
|
2022-07-16 18:10:25 -07:00
|
|
|
|
call assert_equal('Xtestfile2', @%)
|
2019-09-01 08:46:07 -07:00
|
|
|
|
call assert_equal(4, line('.'))
|
|
|
|
|
autocmd! QuickFixCmdPost
|
|
|
|
|
|
|
|
|
|
" Test for cbuffer/lbuffer
|
|
|
|
|
call g:Xsetlist([], 'f')
|
|
|
|
|
Xexpr 'Xtestfile1:2:Line2'
|
|
|
|
|
autocmd QuickFixCmdPost * Xolder
|
|
|
|
|
call writefile(['Xtestfile2:4:Line4'], 'Xerr')
|
|
|
|
|
edit Xerr
|
|
|
|
|
Xbuffer
|
2022-07-16 18:10:25 -07:00
|
|
|
|
call assert_equal('Xtestfile2', @%)
|
2019-09-01 08:46:07 -07:00
|
|
|
|
call assert_equal(4, line('.'))
|
|
|
|
|
autocmd! QuickFixCmdPost
|
|
|
|
|
|
|
|
|
|
" Test for cexpr/lexpr
|
|
|
|
|
call g:Xsetlist([], 'f')
|
|
|
|
|
Xexpr 'Xtestfile1:2:Line2'
|
|
|
|
|
autocmd QuickFixCmdPost * Xolder
|
|
|
|
|
Xexpr 'Xtestfile2:4:Line4'
|
2022-07-16 18:10:25 -07:00
|
|
|
|
call assert_equal('Xtestfile2', @%)
|
2019-09-01 08:46:07 -07:00
|
|
|
|
call assert_equal(4, line('.'))
|
|
|
|
|
autocmd! QuickFixCmdPost
|
|
|
|
|
|
2019-09-03 23:35:45 -07:00
|
|
|
|
" The grepprg may not be set on non-Unix systems
|
|
|
|
|
if has('unix')
|
|
|
|
|
" Test for grep/lgrep
|
|
|
|
|
call g:Xsetlist([], 'f')
|
|
|
|
|
Xexpr 'Xtestfile1:2:Line2'
|
|
|
|
|
autocmd QuickFixCmdPost * Xolder
|
|
|
|
|
silent Xgrep Line5 Xtestfile2
|
2022-07-16 18:10:25 -07:00
|
|
|
|
call assert_equal('Xtestfile2', @%)
|
2019-09-03 23:35:45 -07:00
|
|
|
|
call assert_equal(5, line('.'))
|
|
|
|
|
autocmd! QuickFixCmdPost
|
|
|
|
|
endif
|
2019-09-01 08:46:07 -07:00
|
|
|
|
|
|
|
|
|
" Test for vimgrep/lvimgrep
|
|
|
|
|
call g:Xsetlist([], 'f')
|
|
|
|
|
Xexpr 'Xtestfile1:2:Line2'
|
|
|
|
|
autocmd QuickFixCmdPost * Xolder
|
|
|
|
|
silent Xvimgrep Line5 Xtestfile2
|
2022-07-16 18:10:25 -07:00
|
|
|
|
call assert_equal('Xtestfile2', @%)
|
2019-09-01 08:46:07 -07:00
|
|
|
|
call assert_equal(5, line('.'))
|
|
|
|
|
autocmd! QuickFixCmdPost
|
|
|
|
|
|
2019-09-12 21:38:42 -07:00
|
|
|
|
" Test for autocommands clearing the quickfix list before jumping to the
|
|
|
|
|
" first error. This should not result in an error
|
|
|
|
|
autocmd QuickFixCmdPost * call g:Xsetlist([], 'r')
|
|
|
|
|
let v:errmsg = ''
|
|
|
|
|
" Test for cfile/lfile
|
|
|
|
|
Xfile Xerr
|
|
|
|
|
call assert_true(v:errmsg !~# 'E42:')
|
|
|
|
|
" Test for cbuffer/lbuffer
|
|
|
|
|
edit Xerr
|
|
|
|
|
Xbuffer
|
|
|
|
|
call assert_true(v:errmsg !~# 'E42:')
|
|
|
|
|
" Test for cexpr/lexpr
|
|
|
|
|
Xexpr 'Xtestfile2:4:Line4'
|
|
|
|
|
call assert_true(v:errmsg !~# 'E42:')
|
|
|
|
|
" Test for grep/lgrep
|
|
|
|
|
" The grepprg may not be set on non-Unix systems
|
|
|
|
|
if has('unix')
|
|
|
|
|
silent Xgrep Line5 Xtestfile2
|
|
|
|
|
call assert_true(v:errmsg !~# 'E42:')
|
|
|
|
|
endif
|
|
|
|
|
" Test for vimgrep/lvimgrep
|
|
|
|
|
call assert_fails('silent Xvimgrep Line5 Xtestfile2', 'E480:')
|
|
|
|
|
autocmd! QuickFixCmdPost
|
|
|
|
|
|
2019-09-01 08:46:07 -07:00
|
|
|
|
call delete('Xerr')
|
|
|
|
|
call delete('Xtestfile1')
|
|
|
|
|
call delete('Xtestfile2')
|
|
|
|
|
endfunc
|
|
|
|
|
|
|
|
|
|
func Test_autocmd_changelist()
|
|
|
|
|
call Xautocmd_changelist('c')
|
|
|
|
|
call Xautocmd_changelist('l')
|
|
|
|
|
endfunc
|
|
|
|
|
|
2019-12-02 09:12:26 -07:00
|
|
|
|
" Tests for the ':filter /pat/ clist' command
|
|
|
|
|
func Test_filter_clist()
|
|
|
|
|
cexpr ['Xfile1:10:10:Line 10', 'Xfile2:15:15:Line 15']
|
|
|
|
|
call assert_equal([' 2 Xfile2:15 col 15: Line 15'],
|
|
|
|
|
\ split(execute('filter /Line 15/ clist'), "\n"))
|
|
|
|
|
call assert_equal([' 1 Xfile1:10 col 10: Line 10'],
|
|
|
|
|
\ split(execute('filter /Xfile1/ clist'), "\n"))
|
|
|
|
|
call assert_equal([], split(execute('filter /abc/ clist'), "\n"))
|
|
|
|
|
|
|
|
|
|
call setqflist([{'module' : 'abc', 'pattern' : 'pat1'},
|
|
|
|
|
\ {'module' : 'pqr', 'pattern' : 'pat2'}], ' ')
|
|
|
|
|
call assert_equal([' 2 pqr:pat2: '],
|
|
|
|
|
\ split(execute('filter /pqr/ clist'), "\n"))
|
|
|
|
|
call assert_equal([' 1 abc:pat1: '],
|
|
|
|
|
\ split(execute('filter /pat1/ clist'), "\n"))
|
|
|
|
|
endfunc
|
|
|
|
|
|
2019-06-11 20:16:16 -07:00
|
|
|
|
" Tests for the "CTRL-W <CR>" command.
|
|
|
|
|
func Xview_result_split_tests(cchar)
|
|
|
|
|
call s:setup_commands(a:cchar)
|
|
|
|
|
|
|
|
|
|
" Test that "CTRL-W <CR>" in a qf/ll window fails with empty list.
|
|
|
|
|
call g:Xsetlist([])
|
|
|
|
|
Xopen
|
|
|
|
|
let l:win_count = winnr('$')
|
|
|
|
|
call assert_fails('execute "normal! \<C-W>\<CR>"', 'E42')
|
|
|
|
|
call assert_equal(l:win_count, winnr('$'))
|
|
|
|
|
Xclose
|
|
|
|
|
endfunc
|
|
|
|
|
|
|
|
|
|
func Test_view_result_split()
|
|
|
|
|
call Xview_result_split_tests('c')
|
|
|
|
|
call Xview_result_split_tests('l')
|
|
|
|
|
endfunc
|
2019-09-14 09:30:31 -07:00
|
|
|
|
|
|
|
|
|
" Test that :cc sets curswant
|
|
|
|
|
func Test_curswant()
|
|
|
|
|
helpgrep quickfix
|
|
|
|
|
normal! llll
|
|
|
|
|
1cc
|
|
|
|
|
call assert_equal(getcurpos()[4], virtcol('.'))
|
|
|
|
|
cclose | helpclose
|
|
|
|
|
endfunc
|
2019-10-25 22:17:21 -07:00
|
|
|
|
|
2020-10-10 07:52:24 -07:00
|
|
|
|
" Test for opening a file from the quickfix window using CTRL-W <Enter>
|
|
|
|
|
" doesn't leave an empty buffer around.
|
|
|
|
|
func Test_splitview()
|
|
|
|
|
call s:create_test_file('Xtestfile1')
|
|
|
|
|
call s:create_test_file('Xtestfile2')
|
|
|
|
|
new | only
|
|
|
|
|
let last_bufnr = bufnr('Test_sv_1', 1)
|
|
|
|
|
let l = ['Xtestfile1:2:Line2', 'Xtestfile2:4:Line4']
|
|
|
|
|
cgetexpr l
|
|
|
|
|
copen
|
|
|
|
|
let numbufs = len(getbufinfo())
|
|
|
|
|
exe "normal \<C-W>\<CR>"
|
|
|
|
|
copen
|
|
|
|
|
exe "normal j\<C-W>\<CR>"
|
|
|
|
|
" Make sure new empty buffers are not created
|
|
|
|
|
call assert_equal(numbufs, len(getbufinfo()))
|
|
|
|
|
" Creating a new buffer should use the next available buffer number
|
|
|
|
|
call assert_equal(last_bufnr + 4, bufnr("Test_sv_2", 1))
|
|
|
|
|
bwipe Test_sv_1
|
|
|
|
|
bwipe Test_sv_2
|
|
|
|
|
new | only
|
|
|
|
|
|
|
|
|
|
" When split opening files from location list window, make sure that two
|
|
|
|
|
" windows doesn't refer to the same location list
|
|
|
|
|
lgetexpr l
|
|
|
|
|
let locid = getloclist(0, {'id' : 0}).id
|
|
|
|
|
lopen
|
|
|
|
|
exe "normal \<C-W>\<CR>"
|
|
|
|
|
call assert_notequal(locid, getloclist(0, {'id' : 0}).id)
|
|
|
|
|
call assert_equal(0, getloclist(0, {'winid' : 0}).winid)
|
|
|
|
|
new | only
|
|
|
|
|
|
|
|
|
|
" When split opening files from a helpgrep location list window, a new help
|
2021-12-19 00:46:28 -07:00
|
|
|
|
" window should be opened with a copy of the location list.
|
2020-10-10 07:52:24 -07:00
|
|
|
|
lhelpgrep window
|
|
|
|
|
let locid = getloclist(0, {'id' : 0}).id
|
|
|
|
|
lwindow
|
|
|
|
|
exe "normal j\<C-W>\<CR>"
|
|
|
|
|
call assert_notequal(locid, getloclist(0, {'id' : 0}).id)
|
|
|
|
|
call assert_equal(0, getloclist(0, {'winid' : 0}).winid)
|
|
|
|
|
new | only
|
|
|
|
|
|
2022-07-11 22:28:17 -07:00
|
|
|
|
" Using :split or :vsplit from a quickfix window should behave like a :new
|
|
|
|
|
" or a :vnew command
|
|
|
|
|
copen
|
|
|
|
|
split
|
|
|
|
|
call assert_equal(3, winnr('$'))
|
|
|
|
|
let l = getwininfo()
|
|
|
|
|
call assert_equal([0, 0, 1], [l[0].quickfix, l[1].quickfix, l[2].quickfix])
|
|
|
|
|
close
|
|
|
|
|
copen
|
|
|
|
|
vsplit
|
|
|
|
|
let l = getwininfo()
|
|
|
|
|
call assert_equal([0, 0, 1], [l[0].quickfix, l[1].quickfix, l[2].quickfix])
|
|
|
|
|
new | only
|
|
|
|
|
|
2020-10-10 07:52:24 -07:00
|
|
|
|
call delete('Xtestfile1')
|
|
|
|
|
call delete('Xtestfile2')
|
|
|
|
|
endfunc
|
|
|
|
|
|
2019-10-25 22:17:21 -07:00
|
|
|
|
" Test for parsing entries using visual screen column
|
|
|
|
|
func Test_viscol()
|
|
|
|
|
enew
|
|
|
|
|
call writefile(["Col1\tCol2\tCol3"], 'Xfile1')
|
|
|
|
|
edit Xfile1
|
|
|
|
|
|
|
|
|
|
" Use byte offset for column number
|
|
|
|
|
set efm&
|
|
|
|
|
cexpr "Xfile1:1:5:XX\nXfile1:1:9:YY\nXfile1:1:20:ZZ"
|
|
|
|
|
call assert_equal([5, 8], [col('.'), virtcol('.')])
|
|
|
|
|
cnext
|
|
|
|
|
call assert_equal([9, 12], [col('.'), virtcol('.')])
|
|
|
|
|
cnext
|
|
|
|
|
call assert_equal([14, 20], [col('.'), virtcol('.')])
|
|
|
|
|
|
|
|
|
|
" Use screen column offset for column number
|
|
|
|
|
set efm=%f:%l:%v:%m
|
|
|
|
|
cexpr "Xfile1:1:8:XX\nXfile1:1:12:YY\nXfile1:1:20:ZZ"
|
|
|
|
|
call assert_equal([5, 8], [col('.'), virtcol('.')])
|
|
|
|
|
cnext
|
|
|
|
|
call assert_equal([9, 12], [col('.'), virtcol('.')])
|
|
|
|
|
cnext
|
|
|
|
|
call assert_equal([14, 20], [col('.'), virtcol('.')])
|
|
|
|
|
cexpr "Xfile1:1:6:XX\nXfile1:1:15:YY\nXfile1:1:24:ZZ"
|
|
|
|
|
call assert_equal([5, 8], [col('.'), virtcol('.')])
|
|
|
|
|
cnext
|
|
|
|
|
call assert_equal([10, 16], [col('.'), virtcol('.')])
|
|
|
|
|
cnext
|
|
|
|
|
call assert_equal([14, 20], [col('.'), virtcol('.')])
|
|
|
|
|
|
|
|
|
|
enew
|
|
|
|
|
call writefile(["Col1\täü\töß\tCol4"], 'Xfile1')
|
|
|
|
|
|
|
|
|
|
" Use byte offset for column number
|
|
|
|
|
set efm&
|
|
|
|
|
cexpr "Xfile1:1:8:XX\nXfile1:1:11:YY\nXfile1:1:16:ZZ"
|
|
|
|
|
call assert_equal([8, 10], [col('.'), virtcol('.')])
|
|
|
|
|
cnext
|
|
|
|
|
call assert_equal([11, 17], [col('.'), virtcol('.')])
|
|
|
|
|
cnext
|
|
|
|
|
call assert_equal([16, 25], [col('.'), virtcol('.')])
|
|
|
|
|
|
|
|
|
|
" Use screen column offset for column number
|
|
|
|
|
set efm=%f:%l:%v:%m
|
|
|
|
|
cexpr "Xfile1:1:10:XX\nXfile1:1:17:YY\nXfile1:1:25:ZZ"
|
|
|
|
|
call assert_equal([8, 10], [col('.'), virtcol('.')])
|
|
|
|
|
cnext
|
|
|
|
|
call assert_equal([11, 17], [col('.'), virtcol('.')])
|
|
|
|
|
cnext
|
|
|
|
|
call assert_equal([16, 25], [col('.'), virtcol('.')])
|
|
|
|
|
|
2020-10-20 06:31:35 -07:00
|
|
|
|
" Use screen column number with a multi-line error message
|
|
|
|
|
enew
|
|
|
|
|
call writefile(["à test"], 'Xfile1')
|
|
|
|
|
set efm=%E===\ %f\ ===,%C%l:%v,%Z%m
|
|
|
|
|
cexpr ["=== Xfile1 ===", "1:3", "errormsg"]
|
|
|
|
|
call assert_equal('Xfile1', @%)
|
|
|
|
|
call assert_equal([0, 1, 4, 0], getpos('.'))
|
|
|
|
|
|
|
|
|
|
" Repeat previous test with byte offset %c: ensure that fix to issue #7145
|
|
|
|
|
" does not break this
|
|
|
|
|
set efm=%E===\ %f\ ===,%C%l:%c,%Z%m
|
|
|
|
|
cexpr ["=== Xfile1 ===", "1:3", "errormsg"]
|
|
|
|
|
call assert_equal('Xfile1', @%)
|
|
|
|
|
call assert_equal([0, 1, 3, 0], getpos('.'))
|
|
|
|
|
|
2019-10-25 22:17:21 -07:00
|
|
|
|
enew | only
|
|
|
|
|
set efm&
|
|
|
|
|
call delete('Xfile1')
|
|
|
|
|
endfunc
|
2019-10-26 17:06:29 -07:00
|
|
|
|
|
2020-10-10 10:11:34 -07:00
|
|
|
|
" Test for the quickfix window buffer
|
|
|
|
|
func Xqfbuf_test(cchar)
|
|
|
|
|
call s:setup_commands(a:cchar)
|
|
|
|
|
|
|
|
|
|
" Quickfix buffer should be reused across closing and opening a quickfix
|
|
|
|
|
" window
|
|
|
|
|
Xexpr "F1:10:Line10"
|
|
|
|
|
Xopen
|
|
|
|
|
let qfbnum = bufnr('')
|
|
|
|
|
Xclose
|
|
|
|
|
" Even after the quickfix window is closed, the buffer should be loaded
|
|
|
|
|
call assert_true(bufloaded(qfbnum))
|
2020-10-10 12:42:25 -07:00
|
|
|
|
call assert_true(qfbnum, g:Xgetlist({'qfbufnr' : 0}).qfbufnr)
|
2020-10-10 10:11:34 -07:00
|
|
|
|
Xopen
|
|
|
|
|
" Buffer should be reused when opening the window again
|
|
|
|
|
call assert_equal(qfbnum, bufnr(''))
|
|
|
|
|
Xclose
|
|
|
|
|
|
2021-12-19 04:06:16 -07:00
|
|
|
|
" When quickfix buffer is wiped out, getqflist() should return 0
|
|
|
|
|
%bw!
|
|
|
|
|
Xexpr ""
|
|
|
|
|
Xopen
|
|
|
|
|
bw!
|
|
|
|
|
call assert_equal(0, g:Xgetlist({'qfbufnr': 0}).qfbufnr)
|
|
|
|
|
|
2020-10-10 10:11:34 -07:00
|
|
|
|
if a:cchar == 'l'
|
|
|
|
|
%bwipe
|
|
|
|
|
" For a location list, when both the file window and the location list
|
|
|
|
|
" window for the list are closed, then the buffer should be freed.
|
|
|
|
|
new | only
|
|
|
|
|
lexpr "F1:10:Line10"
|
|
|
|
|
let wid = win_getid()
|
|
|
|
|
lopen
|
|
|
|
|
let qfbnum = bufnr('')
|
|
|
|
|
call assert_match(qfbnum . ' %a- "\[Location List]"', execute('ls'))
|
|
|
|
|
close
|
|
|
|
|
" When the location list window is closed, the buffer name should not
|
|
|
|
|
" change to 'Quickfix List'
|
2020-10-10 12:42:25 -07:00
|
|
|
|
call assert_match(qfbnum . 'u h- "\[Location List]"', execute('ls!'))
|
2020-10-10 10:11:34 -07:00
|
|
|
|
call assert_true(bufloaded(qfbnum))
|
|
|
|
|
|
2020-10-10 12:22:05 -07:00
|
|
|
|
" After deleting a location list buffer using ":bdelete", opening the
|
|
|
|
|
" location list window should mark the buffer as a location list buffer.
|
|
|
|
|
exe "bdelete " . qfbnum
|
|
|
|
|
lopen
|
|
|
|
|
call assert_equal("quickfix", &buftype)
|
|
|
|
|
call assert_equal(1, getwininfo(win_getid(winnr()))[0].loclist)
|
|
|
|
|
call assert_equal(wid, getloclist(0, {'filewinid' : 0}).filewinid)
|
|
|
|
|
call assert_false(&swapfile)
|
|
|
|
|
lclose
|
|
|
|
|
|
|
|
|
|
" When the location list is cleared for the window, the buffer should be
|
|
|
|
|
" removed
|
|
|
|
|
call setloclist(0, [], 'f')
|
|
|
|
|
call assert_false(bufexists(qfbnum))
|
2020-10-10 12:42:25 -07:00
|
|
|
|
call assert_equal(0, getloclist(0, {'qfbufnr' : 0}).qfbufnr)
|
2020-10-10 12:22:05 -07:00
|
|
|
|
|
|
|
|
|
" When the location list is freed with the location list window open, the
|
|
|
|
|
" location list buffer should not be lost. It should be reused when the
|
|
|
|
|
" location list is again populated.
|
|
|
|
|
lexpr "F1:10:Line10"
|
|
|
|
|
lopen
|
|
|
|
|
let wid = win_getid()
|
|
|
|
|
let qfbnum = bufnr('')
|
|
|
|
|
wincmd p
|
|
|
|
|
call setloclist(0, [], 'f')
|
|
|
|
|
lexpr "F1:10:Line10"
|
|
|
|
|
lopen
|
|
|
|
|
call assert_equal(wid, win_getid())
|
|
|
|
|
call assert_equal(qfbnum, bufnr(''))
|
|
|
|
|
lclose
|
|
|
|
|
|
|
|
|
|
" When the window with the location list is closed, the buffer should be
|
|
|
|
|
" removed
|
2020-10-10 10:11:34 -07:00
|
|
|
|
new | only
|
2020-10-10 12:22:05 -07:00
|
|
|
|
call assert_false(bufexists(qfbnum))
|
2020-10-10 10:11:34 -07:00
|
|
|
|
endif
|
|
|
|
|
endfunc
|
|
|
|
|
|
|
|
|
|
func Test_qfbuf()
|
|
|
|
|
call Xqfbuf_test('c')
|
|
|
|
|
call Xqfbuf_test('l')
|
|
|
|
|
endfunc
|
|
|
|
|
|
2021-12-19 00:46:28 -07:00
|
|
|
|
" If there is an autocmd to use only one window, then opening the location
|
|
|
|
|
" list window used to crash Vim.
|
|
|
|
|
func Test_winonly_autocmd()
|
|
|
|
|
call s:create_test_file('Xtest1')
|
|
|
|
|
" Autocmd to show only one Vim window at a time
|
|
|
|
|
autocmd WinEnter * only
|
|
|
|
|
new
|
|
|
|
|
" Load the location list
|
|
|
|
|
lexpr "Xtest1:5:Line5\nXtest1:10:Line10\nXtest1:15:Line15"
|
|
|
|
|
let loclistid = getloclist(0, {'id' : 0}).id
|
|
|
|
|
" Open the location list window. Only this window will be shown and the file
|
|
|
|
|
" window is closed.
|
|
|
|
|
lopen
|
|
|
|
|
call assert_equal(loclistid, getloclist(0, {'id' : 0}).id)
|
|
|
|
|
" Jump to an entry in the location list and make sure that the cursor is
|
|
|
|
|
" positioned correctly.
|
|
|
|
|
ll 3
|
|
|
|
|
call assert_equal(loclistid, getloclist(0, {'id' : 0}).id)
|
2022-07-16 18:10:25 -07:00
|
|
|
|
call assert_equal('Xtest1', @%)
|
2021-12-19 00:46:28 -07:00
|
|
|
|
call assert_equal(15, line('.'))
|
|
|
|
|
" Cleanup
|
|
|
|
|
autocmd! WinEnter
|
|
|
|
|
new | only
|
|
|
|
|
call delete('Xtest1')
|
|
|
|
|
endfunc
|
|
|
|
|
|
2019-12-02 09:12:26 -07:00
|
|
|
|
" Test to make sure that an empty quickfix buffer is not reused for loading
|
|
|
|
|
" a normal buffer.
|
|
|
|
|
func Test_empty_qfbuf()
|
|
|
|
|
enew | only
|
|
|
|
|
call writefile(["Test"], 'Xfile1')
|
|
|
|
|
call setqflist([], 'f')
|
|
|
|
|
copen | only
|
|
|
|
|
let qfbuf = bufnr('')
|
|
|
|
|
edit Xfile1
|
|
|
|
|
call assert_notequal(qfbuf, bufnr(''))
|
|
|
|
|
enew
|
|
|
|
|
call delete('Xfile1')
|
|
|
|
|
endfunc
|
|
|
|
|
|
2019-09-13 19:16:12 -07:00
|
|
|
|
" Test for the :cbelow, :cabove, :lbelow and :labove commands.
|
2021-01-01 01:32:43 -07:00
|
|
|
|
" And for the :cafter, :cbefore, :lafter and :lbefore commands.
|
2019-09-13 19:16:12 -07:00
|
|
|
|
func Xtest_below(cchar)
|
|
|
|
|
call s:setup_commands(a:cchar)
|
|
|
|
|
|
|
|
|
|
" No quickfix/location list
|
|
|
|
|
call assert_fails('Xbelow', 'E42:')
|
|
|
|
|
call assert_fails('Xabove', 'E42:')
|
2021-01-01 01:32:43 -07:00
|
|
|
|
call assert_fails('Xbefore', 'E42:')
|
|
|
|
|
call assert_fails('Xafter', 'E42:')
|
2019-09-13 19:16:12 -07:00
|
|
|
|
|
|
|
|
|
" Empty quickfix/location list
|
|
|
|
|
call g:Xsetlist([])
|
|
|
|
|
call assert_fails('Xbelow', 'E42:')
|
|
|
|
|
call assert_fails('Xabove', 'E42:')
|
2021-01-01 01:32:43 -07:00
|
|
|
|
call assert_fails('Xbefore', 'E42:')
|
|
|
|
|
call assert_fails('Xafter', 'E42:')
|
2019-09-13 19:16:12 -07:00
|
|
|
|
|
|
|
|
|
call s:create_test_file('X1')
|
|
|
|
|
call s:create_test_file('X2')
|
|
|
|
|
call s:create_test_file('X3')
|
|
|
|
|
call s:create_test_file('X4')
|
|
|
|
|
|
|
|
|
|
" Invalid entries
|
|
|
|
|
edit X1
|
|
|
|
|
call g:Xsetlist(["E1", "E2"])
|
|
|
|
|
call assert_fails('Xbelow', 'E42:')
|
|
|
|
|
call assert_fails('Xabove', 'E42:')
|
|
|
|
|
call assert_fails('3Xbelow', 'E42:')
|
|
|
|
|
call assert_fails('4Xabove', 'E42:')
|
2021-01-01 01:32:43 -07:00
|
|
|
|
call assert_fails('Xbefore', 'E42:')
|
|
|
|
|
call assert_fails('Xafter', 'E42:')
|
|
|
|
|
call assert_fails('3Xbefore', 'E42:')
|
|
|
|
|
call assert_fails('4Xafter', 'E42:')
|
2019-09-13 19:16:12 -07:00
|
|
|
|
|
|
|
|
|
" Test the commands with various arguments
|
2021-01-01 01:32:43 -07:00
|
|
|
|
Xexpr ["X1:5:3:L5", "X2:5:2:L5", "X2:10:3:L10", "X2:15:4:L15", "X3:3:5:L3"]
|
2019-09-13 19:16:12 -07:00
|
|
|
|
edit +7 X2
|
|
|
|
|
Xabove
|
2022-07-16 18:10:25 -07:00
|
|
|
|
call assert_equal(['X2', 5], [@%, line('.')])
|
2019-09-13 19:16:12 -07:00
|
|
|
|
call assert_fails('Xabove', 'E553:')
|
2021-01-01 01:32:43 -07:00
|
|
|
|
normal 7G
|
|
|
|
|
Xbefore
|
2022-07-16 18:10:25 -07:00
|
|
|
|
call assert_equal(['X2', 5, 2], [@%, line('.'), col('.')])
|
2021-01-01 01:32:43 -07:00
|
|
|
|
call assert_fails('Xbefore', 'E553:')
|
|
|
|
|
|
2019-09-13 19:16:12 -07:00
|
|
|
|
normal 2j
|
|
|
|
|
Xbelow
|
2022-07-16 18:10:25 -07:00
|
|
|
|
call assert_equal(['X2', 10], [@%, line('.')])
|
2021-01-01 01:32:43 -07:00
|
|
|
|
normal 7G
|
|
|
|
|
Xafter
|
2022-07-16 18:10:25 -07:00
|
|
|
|
call assert_equal(['X2', 10, 3], [@%, line('.'), col('.')])
|
2021-01-01 01:32:43 -07:00
|
|
|
|
|
2019-09-13 19:16:12 -07:00
|
|
|
|
" Last error in this file
|
|
|
|
|
Xbelow 99
|
2022-07-16 18:10:25 -07:00
|
|
|
|
call assert_equal(['X2', 15], [@%, line('.')])
|
2019-09-13 19:16:12 -07:00
|
|
|
|
call assert_fails('Xbelow', 'E553:')
|
2021-01-01 01:32:43 -07:00
|
|
|
|
normal gg
|
|
|
|
|
Xafter 99
|
2022-07-16 18:10:25 -07:00
|
|
|
|
call assert_equal(['X2', 15, 4], [@%, line('.'), col('.')])
|
2021-01-01 01:32:43 -07:00
|
|
|
|
call assert_fails('Xafter', 'E553:')
|
|
|
|
|
|
2019-09-13 19:16:12 -07:00
|
|
|
|
" First error in this file
|
|
|
|
|
Xabove 99
|
2022-07-16 18:10:25 -07:00
|
|
|
|
call assert_equal(['X2', 5], [@%, line('.')])
|
2019-09-13 19:16:12 -07:00
|
|
|
|
call assert_fails('Xabove', 'E553:')
|
2021-01-01 01:32:43 -07:00
|
|
|
|
normal G
|
|
|
|
|
Xbefore 99
|
2022-07-16 18:10:25 -07:00
|
|
|
|
call assert_equal(['X2', 5, 2], [@%, line('.'), col('.')])
|
2021-01-01 01:32:43 -07:00
|
|
|
|
call assert_fails('Xbefore', 'E553:')
|
|
|
|
|
|
2019-09-13 19:16:12 -07:00
|
|
|
|
normal gg
|
|
|
|
|
Xbelow 2
|
2022-07-16 18:10:25 -07:00
|
|
|
|
call assert_equal(['X2', 10], [@%, line('.')])
|
2021-01-01 01:32:43 -07:00
|
|
|
|
normal gg
|
|
|
|
|
Xafter 2
|
2022-07-16 18:10:25 -07:00
|
|
|
|
call assert_equal(['X2', 10, 3], [@%, line('.'), col('.')])
|
2021-01-01 01:32:43 -07:00
|
|
|
|
|
2019-09-13 19:16:12 -07:00
|
|
|
|
normal G
|
|
|
|
|
Xabove 2
|
2022-07-16 18:10:25 -07:00
|
|
|
|
call assert_equal(['X2', 10], [@%, line('.')])
|
2021-01-01 01:32:43 -07:00
|
|
|
|
normal G
|
|
|
|
|
Xbefore 2
|
2022-07-16 18:10:25 -07:00
|
|
|
|
call assert_equal(['X2', 10, 3], [@%, line('.'), col('.')])
|
2021-01-01 01:32:43 -07:00
|
|
|
|
|
2019-09-13 19:16:12 -07:00
|
|
|
|
edit X4
|
|
|
|
|
call assert_fails('Xabove', 'E42:')
|
|
|
|
|
call assert_fails('Xbelow', 'E42:')
|
2021-01-01 01:32:43 -07:00
|
|
|
|
call assert_fails('Xbefore', 'E42:')
|
|
|
|
|
call assert_fails('Xafter', 'E42:')
|
2019-09-13 19:16:12 -07:00
|
|
|
|
if a:cchar == 'l'
|
|
|
|
|
" If a buffer has location list entries from some other window but not
|
|
|
|
|
" from the current window, then the commands should fail.
|
|
|
|
|
edit X1 | split | call setloclist(0, [], 'f')
|
|
|
|
|
call assert_fails('Xabove', 'E776:')
|
|
|
|
|
call assert_fails('Xbelow', 'E776:')
|
2021-01-01 01:32:43 -07:00
|
|
|
|
call assert_fails('Xbefore', 'E776:')
|
|
|
|
|
call assert_fails('Xafter', 'E776:')
|
2019-09-13 19:16:12 -07:00
|
|
|
|
close
|
|
|
|
|
endif
|
|
|
|
|
|
|
|
|
|
" Test for lines with multiple quickfix entries
|
2022-10-12 23:31:10 -07:00
|
|
|
|
let lines =<< trim END
|
|
|
|
|
X1:5:L5
|
|
|
|
|
X2:5:1:L5_1
|
|
|
|
|
X2:5:2:L5_2
|
|
|
|
|
X2:5:3:L5_3
|
|
|
|
|
X2:10:1:L10_1
|
|
|
|
|
X2:10:2:L10_2
|
|
|
|
|
X2:10:3:L10_3
|
|
|
|
|
X2:15:1:L15_1
|
|
|
|
|
X2:15:2:L15_2
|
|
|
|
|
X2:15:3:L15_3
|
|
|
|
|
X3:3:L3
|
|
|
|
|
END
|
|
|
|
|
Xexpr lines
|
2019-09-13 19:16:12 -07:00
|
|
|
|
edit +1 X2
|
|
|
|
|
Xbelow 2
|
2022-07-16 18:10:25 -07:00
|
|
|
|
call assert_equal(['X2', 10, 1], [@%, line('.'), col('.')])
|
2021-01-01 01:32:43 -07:00
|
|
|
|
normal 1G
|
|
|
|
|
Xafter 2
|
2022-07-16 18:10:25 -07:00
|
|
|
|
call assert_equal(['X2', 5, 2], [@%, line('.'), col('.')])
|
2021-01-01 01:32:43 -07:00
|
|
|
|
|
2019-09-13 19:16:12 -07:00
|
|
|
|
normal gg
|
|
|
|
|
Xbelow 99
|
2022-07-16 18:10:25 -07:00
|
|
|
|
call assert_equal(['X2', 15, 1], [@%, line('.'), col('.')])
|
2021-01-01 01:32:43 -07:00
|
|
|
|
normal gg
|
|
|
|
|
Xafter 99
|
2022-07-16 18:10:25 -07:00
|
|
|
|
call assert_equal(['X2', 15, 3], [@%, line('.'), col('.')])
|
2021-01-01 01:32:43 -07:00
|
|
|
|
|
2019-09-13 19:16:12 -07:00
|
|
|
|
normal G
|
|
|
|
|
Xabove 2
|
2022-07-16 18:10:25 -07:00
|
|
|
|
call assert_equal(['X2', 10, 1], [@%, line('.'), col('.')])
|
2021-01-01 01:32:43 -07:00
|
|
|
|
normal G
|
|
|
|
|
Xbefore 2
|
2022-07-16 18:10:25 -07:00
|
|
|
|
call assert_equal(['X2', 15, 2], [@%, line('.'), col('.')])
|
2021-01-01 01:32:43 -07:00
|
|
|
|
|
2019-09-13 19:16:12 -07:00
|
|
|
|
normal G
|
|
|
|
|
Xabove 99
|
2022-07-16 18:10:25 -07:00
|
|
|
|
call assert_equal(['X2', 5, 1], [@%, line('.'), col('.')])
|
2021-01-01 01:32:43 -07:00
|
|
|
|
normal G
|
|
|
|
|
Xbefore 99
|
2022-07-16 18:10:25 -07:00
|
|
|
|
call assert_equal(['X2', 5, 1], [@%, line('.'), col('.')])
|
2021-01-01 01:32:43 -07:00
|
|
|
|
|
2019-09-13 19:16:12 -07:00
|
|
|
|
normal 10G
|
|
|
|
|
Xabove
|
2022-07-16 18:10:25 -07:00
|
|
|
|
call assert_equal(['X2', 5, 1], [@%, line('.'), col('.')])
|
2021-01-01 01:32:43 -07:00
|
|
|
|
normal 10G$
|
|
|
|
|
2Xbefore
|
2022-07-16 18:10:25 -07:00
|
|
|
|
call assert_equal(['X2', 10, 2], [@%, line('.'), col('.')])
|
2021-01-01 01:32:43 -07:00
|
|
|
|
|
2019-09-13 19:16:12 -07:00
|
|
|
|
normal 10G
|
|
|
|
|
Xbelow
|
2022-07-16 18:10:25 -07:00
|
|
|
|
call assert_equal(['X2', 15, 1], [@%, line('.'), col('.')])
|
2021-01-01 01:32:43 -07:00
|
|
|
|
normal 9G
|
|
|
|
|
5Xafter
|
2022-07-16 18:10:25 -07:00
|
|
|
|
call assert_equal(['X2', 15, 2], [@%, line('.'), col('.')])
|
2019-09-13 19:16:12 -07:00
|
|
|
|
|
|
|
|
|
" Invalid range
|
|
|
|
|
if a:cchar == 'c'
|
2020-10-12 18:02:36 -07:00
|
|
|
|
call assert_fails('-2cbelow', 'E16:')
|
2021-01-01 01:32:43 -07:00
|
|
|
|
call assert_fails('-2cafter', 'E16:')
|
2019-09-13 19:16:12 -07:00
|
|
|
|
else
|
2020-10-12 18:02:36 -07:00
|
|
|
|
call assert_fails('-2lbelow', 'E16:')
|
2021-01-01 01:32:43 -07:00
|
|
|
|
call assert_fails('-2lafter', 'E16:')
|
2019-09-13 19:16:12 -07:00
|
|
|
|
endif
|
|
|
|
|
|
|
|
|
|
call delete('X1')
|
|
|
|
|
call delete('X2')
|
|
|
|
|
call delete('X3')
|
|
|
|
|
call delete('X4')
|
|
|
|
|
endfunc
|
|
|
|
|
|
|
|
|
|
func Test_cbelow()
|
|
|
|
|
call Xtest_below('c')
|
|
|
|
|
call Xtest_below('l')
|
|
|
|
|
endfunc
|
|
|
|
|
|
2020-10-12 18:02:36 -07:00
|
|
|
|
func Test_quickfix_count()
|
2022-10-12 23:31:10 -07:00
|
|
|
|
let commands =<< trim END
|
|
|
|
|
cNext
|
|
|
|
|
cNfile
|
|
|
|
|
cabove
|
|
|
|
|
cbelow
|
|
|
|
|
cfirst
|
|
|
|
|
clast
|
|
|
|
|
cnewer
|
|
|
|
|
cnext
|
|
|
|
|
cnfile
|
|
|
|
|
colder
|
|
|
|
|
cprevious
|
|
|
|
|
crewind
|
|
|
|
|
lNext
|
|
|
|
|
lNfile
|
|
|
|
|
labove
|
|
|
|
|
lbelow
|
|
|
|
|
lfirst
|
|
|
|
|
llast
|
|
|
|
|
lnewer
|
|
|
|
|
lnext
|
|
|
|
|
lnfile
|
|
|
|
|
lolder
|
|
|
|
|
lprevious
|
|
|
|
|
lrewind
|
|
|
|
|
END
|
2020-10-12 18:02:36 -07:00
|
|
|
|
for cmd in commands
|
|
|
|
|
call assert_fails('-1' .. cmd, 'E16:')
|
|
|
|
|
call assert_fails('.' .. cmd, 'E16:')
|
|
|
|
|
call assert_fails('%' .. cmd, 'E16:')
|
|
|
|
|
call assert_fails('$' .. cmd, 'E16:')
|
|
|
|
|
endfor
|
|
|
|
|
endfunc
|
|
|
|
|
|
2019-12-02 09:12:26 -07:00
|
|
|
|
" Test for aborting quickfix commands using QuickFixCmdPre
|
|
|
|
|
func Xtest_qfcmd_abort(cchar)
|
|
|
|
|
call s:setup_commands(a:cchar)
|
|
|
|
|
|
|
|
|
|
call g:Xsetlist([], 'f')
|
|
|
|
|
|
|
|
|
|
" cexpr/lexpr
|
|
|
|
|
let e = ''
|
|
|
|
|
try
|
|
|
|
|
Xexpr ["F1:10:Line10", "F2:20:Line20"]
|
|
|
|
|
catch /.*/
|
|
|
|
|
let e = v:exception
|
|
|
|
|
endtry
|
|
|
|
|
call assert_equal('AbortCmd', e)
|
|
|
|
|
call assert_equal(0, g:Xgetlist({'nr' : '$'}).nr)
|
|
|
|
|
|
|
|
|
|
" cfile/lfile
|
|
|
|
|
call writefile(["F1:10:Line10", "F2:20:Line20"], 'Xfile1')
|
|
|
|
|
let e = ''
|
|
|
|
|
try
|
|
|
|
|
Xfile Xfile1
|
|
|
|
|
catch /.*/
|
|
|
|
|
let e = v:exception
|
|
|
|
|
endtry
|
|
|
|
|
call assert_equal('AbortCmd', e)
|
|
|
|
|
call assert_equal(0, g:Xgetlist({'nr' : '$'}).nr)
|
|
|
|
|
call delete('Xfile1')
|
|
|
|
|
|
|
|
|
|
" cgetbuffer/lgetbuffer
|
|
|
|
|
enew!
|
|
|
|
|
call append(0, ["F1:10:Line10", "F2:20:Line20"])
|
|
|
|
|
let e = ''
|
|
|
|
|
try
|
|
|
|
|
Xgetbuffer
|
|
|
|
|
catch /.*/
|
|
|
|
|
let e = v:exception
|
|
|
|
|
endtry
|
|
|
|
|
call assert_equal('AbortCmd', e)
|
|
|
|
|
call assert_equal(0, g:Xgetlist({'nr' : '$'}).nr)
|
|
|
|
|
enew!
|
|
|
|
|
|
|
|
|
|
" vimgrep/lvimgrep
|
|
|
|
|
let e = ''
|
|
|
|
|
try
|
|
|
|
|
Xvimgrep /func/ test_quickfix.vim
|
|
|
|
|
catch /.*/
|
|
|
|
|
let e = v:exception
|
|
|
|
|
endtry
|
|
|
|
|
call assert_equal('AbortCmd', e)
|
|
|
|
|
call assert_equal(0, g:Xgetlist({'nr' : '$'}).nr)
|
|
|
|
|
|
|
|
|
|
" helpgrep/lhelpgrep
|
|
|
|
|
let e = ''
|
|
|
|
|
try
|
|
|
|
|
Xhelpgrep quickfix
|
|
|
|
|
catch /.*/
|
|
|
|
|
let e = v:exception
|
|
|
|
|
endtry
|
|
|
|
|
call assert_equal('AbortCmd', e)
|
|
|
|
|
call assert_equal(0, g:Xgetlist({'nr' : '$'}).nr)
|
|
|
|
|
|
|
|
|
|
" grep/lgrep
|
|
|
|
|
if has('unix')
|
|
|
|
|
let e = ''
|
|
|
|
|
try
|
|
|
|
|
silent Xgrep func test_quickfix.vim
|
|
|
|
|
catch /.*/
|
|
|
|
|
let e = v:exception
|
|
|
|
|
endtry
|
|
|
|
|
call assert_equal('AbortCmd', e)
|
|
|
|
|
call assert_equal(0, g:Xgetlist({'nr' : '$'}).nr)
|
|
|
|
|
endif
|
|
|
|
|
endfunc
|
|
|
|
|
|
|
|
|
|
func Test_qfcmd_abort()
|
|
|
|
|
augroup QF_Test
|
|
|
|
|
au!
|
|
|
|
|
autocmd QuickFixCmdPre * throw "AbortCmd"
|
|
|
|
|
augroup END
|
|
|
|
|
|
|
|
|
|
call Xtest_qfcmd_abort('c')
|
|
|
|
|
call Xtest_qfcmd_abort('l')
|
|
|
|
|
|
|
|
|
|
augroup QF_Test
|
|
|
|
|
au!
|
|
|
|
|
augroup END
|
|
|
|
|
endfunc
|
|
|
|
|
|
2020-10-05 20:57:37 -07:00
|
|
|
|
" Test for using a file in one of the parent directories.
|
|
|
|
|
func Test_search_in_dirstack()
|
|
|
|
|
call mkdir('Xtestdir/a/b/c', 'p')
|
|
|
|
|
let save_cwd = getcwd()
|
|
|
|
|
call writefile(["X1_L1", "X1_L2"], 'Xtestdir/Xfile1')
|
|
|
|
|
call writefile(["X2_L1", "X2_L2"], 'Xtestdir/a/Xfile2')
|
|
|
|
|
call writefile(["X3_L1", "X3_L2"], 'Xtestdir/a/b/Xfile3')
|
|
|
|
|
call writefile(["X4_L1", "X4_L2"], 'Xtestdir/a/b/c/Xfile4')
|
|
|
|
|
|
|
|
|
|
let lines = "Entering dir Xtestdir\n" .
|
|
|
|
|
\ "Entering dir a\n" .
|
|
|
|
|
\ "Entering dir b\n" .
|
|
|
|
|
\ "Xfile2:2:X2_L2\n" .
|
|
|
|
|
\ "Leaving dir a\n" .
|
|
|
|
|
\ "Xfile1:2:X1_L2\n" .
|
|
|
|
|
\ "Xfile3:1:X3_L1\n" .
|
|
|
|
|
\ "Entering dir c\n" .
|
|
|
|
|
\ "Xfile4:2:X4_L2\n" .
|
2020-10-05 21:07:40 -07:00
|
|
|
|
\ "Leaving dir c\n"
|
2020-10-05 20:57:37 -07:00
|
|
|
|
set efm=%DEntering\ dir\ %f,%XLeaving\ dir\ %f,%f:%l:%m
|
2020-10-05 21:07:40 -07:00
|
|
|
|
cexpr lines .. "Leaving dir Xtestdir|\n" | let next = 1
|
2020-10-05 20:57:37 -07:00
|
|
|
|
call assert_equal(11, getqflist({'size' : 0}).size)
|
|
|
|
|
call assert_equal(4, getqflist({'idx' : 0}).idx)
|
|
|
|
|
call assert_equal('X2_L2', getline('.'))
|
2020-10-05 21:07:40 -07:00
|
|
|
|
call assert_equal(1, next)
|
2020-10-05 20:57:37 -07:00
|
|
|
|
cnext
|
|
|
|
|
call assert_equal(6, getqflist({'idx' : 0}).idx)
|
|
|
|
|
call assert_equal('X1_L2', getline('.'))
|
|
|
|
|
cnext
|
|
|
|
|
call assert_equal(7, getqflist({'idx' : 0}).idx)
|
|
|
|
|
call assert_equal(1, line('$'))
|
|
|
|
|
call assert_equal('', getline(1))
|
|
|
|
|
cnext
|
|
|
|
|
call assert_equal(9, getqflist({'idx' : 0}).idx)
|
|
|
|
|
call assert_equal(1, line('$'))
|
|
|
|
|
call assert_equal('', getline(1))
|
|
|
|
|
|
|
|
|
|
set efm&
|
|
|
|
|
exe 'cd ' . save_cwd
|
|
|
|
|
call delete('Xtestdir', 'rf')
|
|
|
|
|
endfunc
|
|
|
|
|
|
2020-11-28 13:28:57 -07:00
|
|
|
|
" Test for :cquit
|
|
|
|
|
func Test_cquit()
|
|
|
|
|
" Exit Vim with a non-zero value
|
|
|
|
|
if RunVim([], ["cquit 7"], '')
|
|
|
|
|
call assert_equal(7, v:shell_error)
|
|
|
|
|
endif
|
|
|
|
|
|
|
|
|
|
if RunVim([], ["50cquit"], '')
|
|
|
|
|
call assert_equal(50, v:shell_error)
|
|
|
|
|
endif
|
|
|
|
|
|
|
|
|
|
" Exit Vim with default value
|
|
|
|
|
if RunVim([], ["cquit"], '')
|
|
|
|
|
call assert_equal(1, v:shell_error)
|
|
|
|
|
endif
|
|
|
|
|
|
|
|
|
|
" Exit Vim with zero value
|
|
|
|
|
if RunVim([], ["cquit 0"], '')
|
|
|
|
|
call assert_equal(0, v:shell_error)
|
|
|
|
|
endif
|
|
|
|
|
|
|
|
|
|
" Exit Vim with negative value
|
|
|
|
|
call assert_fails('-3cquit', 'E16:')
|
|
|
|
|
endfunc
|
|
|
|
|
|
2021-01-01 11:25:39 -07:00
|
|
|
|
" Running :lhelpgrep command more than once in a help window, doesn't jump to
|
|
|
|
|
" the help topic
|
|
|
|
|
func Test_lhelpgrep_from_help_window()
|
|
|
|
|
call mkdir('Xtestdir/doc', 'p')
|
|
|
|
|
call writefile(['window'], 'Xtestdir/doc/a.txt')
|
|
|
|
|
call writefile(['buffer'], 'Xtestdir/doc/b.txt')
|
|
|
|
|
let save_rtp = &rtp
|
|
|
|
|
let &rtp = 'Xtestdir'
|
|
|
|
|
lhelpgrep window
|
|
|
|
|
lhelpgrep buffer
|
|
|
|
|
call assert_equal('b.txt', fnamemodify(@%, ":p:t"))
|
|
|
|
|
lhelpgrep window
|
|
|
|
|
call assert_equal('a.txt', fnamemodify(@%, ":p:t"))
|
|
|
|
|
let &rtp = save_rtp
|
|
|
|
|
call delete('Xtestdir', 'rf')
|
|
|
|
|
new | only!
|
|
|
|
|
endfunc
|
|
|
|
|
|
2022-12-02 22:48:51 -07:00
|
|
|
|
" Test for the crash fixed by 7.3.715
|
|
|
|
|
func Test_setloclist_crash()
|
|
|
|
|
%bw!
|
|
|
|
|
let g:BufNum = bufnr()
|
|
|
|
|
augroup QF_Test
|
|
|
|
|
au!
|
|
|
|
|
au BufUnload * call setloclist(0, [{'bufnr':g:BufNum, 'lnum':1, 'col':1, 'text': 'tango down'}])
|
|
|
|
|
augroup END
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
lvimgrep /.*/ *.mak
|
|
|
|
|
catch /E926:/
|
|
|
|
|
endtry
|
|
|
|
|
call assert_equal('tango down', getloclist(0, {'items' : 0}).items[0].text)
|
|
|
|
|
call assert_equal(1, getloclist(0, {'size' : 0}).size)
|
|
|
|
|
|
|
|
|
|
augroup QF_Test
|
|
|
|
|
au!
|
|
|
|
|
augroup END
|
|
|
|
|
unlet g:BufNum
|
|
|
|
|
%bw!
|
|
|
|
|
endfunc
|
|
|
|
|
|
2020-11-14 12:31:13 -07:00
|
|
|
|
" Test for adding an invalid entry with the quickfix window open and making
|
|
|
|
|
" sure that the window contents are not changed
|
|
|
|
|
func Test_add_invalid_entry_with_qf_window()
|
|
|
|
|
call setqflist([], 'f')
|
|
|
|
|
cexpr "Xfile1:10:aa"
|
|
|
|
|
copen
|
|
|
|
|
call setqflist(['bb'], 'a')
|
|
|
|
|
call assert_equal(1, line('$'))
|
|
|
|
|
call assert_equal(['Xfile1|10| aa'], getline(1, '$'))
|
2021-07-31 10:48:29 -07:00
|
|
|
|
call assert_equal([{'lnum': 10 , 'end_lnum': 0 , 'bufnr': bufnr('Xfile1') , 'col': 0 , 'end_col': 0 , 'pattern': '' , 'valid': 1 , 'vcol': 0 , 'nr': -1 , 'type': '' , 'module': '' , 'text': 'aa'}] , getqflist())
|
|
|
|
|
|
|
|
|
|
call setqflist([{'lnum': 10 , 'bufnr': bufnr('Xfile1') , 'col': 0 , 'pattern': '' , 'valid': 1 , 'vcol': 0 , 'nr': -1 , 'type': '' , 'module': '' , 'text': 'aa'}] , 'r')
|
|
|
|
|
call assert_equal(1 , line('$'))
|
|
|
|
|
call assert_equal(['Xfile1|10| aa'] , getline(1 , '$'))
|
|
|
|
|
call assert_equal([{'lnum': 10 , 'end_lnum': 0 , 'bufnr': bufnr('Xfile1') , 'col': 0 , 'end_col': 0 , 'pattern': '' , 'valid': 1 , 'vcol': 0 , 'nr': -1 , 'type': '' , 'module': '' , 'text': 'aa'}] , getqflist())
|
|
|
|
|
|
|
|
|
|
call setqflist([{'lnum': 10 , 'end_lnum': 0 , 'bufnr': bufnr('Xfile1') , 'col': 0 , 'end_col': 0 , 'pattern': '' , 'valid': 1 , 'vcol': 0 , 'nr': -1 , 'type': '' , 'module': '' , 'text': 'aa'}] , 'r')
|
|
|
|
|
call assert_equal(1 , line('$'))
|
|
|
|
|
call assert_equal(['Xfile1|10| aa'] , getline(1 , '$'))
|
|
|
|
|
call assert_equal([{'lnum': 10 , 'end_lnum': 0 , 'bufnr': bufnr('Xfile1') , 'col': 0 , 'end_col': 0 , 'pattern': '' , 'valid': 1 , 'vcol': 0 , 'nr': -1 , 'type': '' , 'module': '' , 'text': 'aa'}] , getqflist())
|
|
|
|
|
|
|
|
|
|
call setqflist([{'lnum': 10 , 'end_lnum': -123 , 'bufnr': bufnr('Xfile1') , 'col': 0 , 'end_col': -456 , 'pattern': '' , 'valid': 1 , 'vcol': 0 , 'nr': -1 , 'type': '' , 'module': '' , 'text': 'aa'}] , 'r')
|
|
|
|
|
call assert_equal(1 , line('$'))
|
|
|
|
|
call assert_equal(['Xfile1|10| aa'] , getline(1 , '$'))
|
|
|
|
|
call assert_equal([{'lnum': 10 , 'end_lnum': -123 , 'bufnr': bufnr('Xfile1') , 'col': 0 , 'end_col': -456 , 'pattern': '' , 'valid': 1 , 'vcol': 0 , 'nr': -1 , 'type': '' , 'module': '' , 'text': 'aa'}] , getqflist())
|
|
|
|
|
|
|
|
|
|
call setqflist([{'lnum': 10 , 'end_lnum': -123 , 'bufnr': bufnr('Xfile1') , 'col': 666 , 'end_col': 0 , 'pattern': '' , 'valid': 1 , 'vcol': 0 , 'nr': -1 , 'type': '' , 'module': '' , 'text': 'aa'}] , 'r')
|
|
|
|
|
call assert_equal(1 , line('$'))
|
|
|
|
|
call assert_equal(['Xfile1|10 col 666| aa'] , getline(1 , '$'))
|
|
|
|
|
call assert_equal([{'lnum': 10 , 'end_lnum': -123 , 'bufnr': bufnr('Xfile1') , 'col': 666 , 'end_col': 0 , 'pattern': '' , 'valid': 1 , 'vcol': 0 , 'nr': -1 , 'type': '' , 'module': '' , 'text': 'aa'}] , getqflist())
|
|
|
|
|
|
|
|
|
|
call setqflist([{'lnum': 10 , 'end_lnum': -123 , 'bufnr': bufnr('Xfile1') , 'col': 666 , 'end_col': -456 , 'pattern': '' , 'valid': 1 , 'vcol': 0 , 'nr': -1 , 'type': '' , 'module': '' , 'text': 'aa'}] , 'r')
|
|
|
|
|
call assert_equal(1 , line('$'))
|
|
|
|
|
call assert_equal(['Xfile1|10 col 666| aa'] , getline(1 , '$'))
|
|
|
|
|
call assert_equal([{'lnum': 10 , 'end_lnum': -123 , 'bufnr': bufnr('Xfile1') , 'col': 666 , 'end_col': -456 , 'pattern': '' , 'valid': 1 , 'vcol': 0 , 'nr': -1 , 'type': '' , 'module': '' , 'text': 'aa'}] , getqflist())
|
|
|
|
|
|
|
|
|
|
call setqflist([{'lnum': 10 , 'end_lnum': -123 , 'bufnr': bufnr('Xfile1') , 'col': 666 , 'end_col': 222 , 'pattern': '' , 'valid': 1 , 'vcol': 0 , 'nr': -1 , 'type': '' , 'module': '' , 'text': 'aa'}] , 'r')
|
|
|
|
|
call assert_equal(1 , line('$'))
|
|
|
|
|
call assert_equal(['Xfile1|10 col 666-222| aa'] , getline(1 , '$'))
|
|
|
|
|
call assert_equal([{'lnum': 10 , 'end_lnum': -123 , 'bufnr': bufnr('Xfile1') , 'col': 666 , 'end_col': 222 , 'pattern': '' , 'valid': 1 , 'vcol': 0 , 'nr': -1 , 'type': '' , 'module': '' , 'text': 'aa'}] , getqflist())
|
|
|
|
|
|
|
|
|
|
call setqflist([{'lnum': 10 , 'end_lnum': 6 , 'bufnr': bufnr('Xfile1') , 'col': 666 , 'end_col': 222 , 'pattern': '' , 'valid': 1 , 'vcol': 0 , 'nr': -1 , 'type': '' , 'module': '' , 'text': 'aa'}] , 'r')
|
|
|
|
|
call assert_equal(1 , line('$'))
|
|
|
|
|
call assert_equal(['Xfile1|10-6 col 666-222| aa'] , getline(1 , '$'))
|
|
|
|
|
call assert_equal([{'lnum': 10 , 'end_lnum': 6 , 'bufnr': bufnr('Xfile1') , 'col': 666 , 'end_col': 222 , 'pattern': '' , 'valid': 1 , 'vcol': 0 , 'nr': -1 , 'type': '' , 'module': '' , 'text': 'aa'}] , getqflist())
|
2020-11-14 12:31:13 -07:00
|
|
|
|
cclose
|
|
|
|
|
endfunc
|
|
|
|
|
|
2020-11-24 07:12:58 -07:00
|
|
|
|
" Test for very weird problem: autocommand causes a failure, resulting opening
|
|
|
|
|
" the quickfix window to fail. This still splits the window, but otherwise
|
|
|
|
|
" should not mess up buffers.
|
|
|
|
|
func Test_quickfix_window_fails_to_open()
|
|
|
|
|
CheckScreendump
|
|
|
|
|
|
|
|
|
|
let lines =<< trim END
|
|
|
|
|
anything
|
|
|
|
|
try
|
|
|
|
|
anything
|
|
|
|
|
endtry
|
|
|
|
|
END
|
|
|
|
|
call writefile(lines, 'XquickfixFails')
|
|
|
|
|
|
|
|
|
|
let lines =<< trim END
|
|
|
|
|
split XquickfixFails
|
|
|
|
|
silent vimgrep anything %
|
|
|
|
|
normal o
|
|
|
|
|
au BufLeave * ++once source XquickfixFails
|
|
|
|
|
" This will trigger the autocommand, which causes an error, what follows
|
|
|
|
|
" is aborted but the window was already split.
|
|
|
|
|
silent! cwindow
|
|
|
|
|
END
|
|
|
|
|
call writefile(lines, 'XtestWinFails')
|
|
|
|
|
let buf = RunVimInTerminal('-S XtestWinFails', #{rows: 13})
|
|
|
|
|
call VerifyScreenDump(buf, 'Test_quickfix_window_fails', {})
|
|
|
|
|
|
|
|
|
|
" clean up
|
|
|
|
|
call term_sendkeys(buf, ":bwipe!\<CR>")
|
|
|
|
|
call term_wait(buf)
|
|
|
|
|
call StopVimInTerminal(buf)
|
|
|
|
|
call delete('XtestWinFails')
|
|
|
|
|
call delete('XquickfixFails')
|
|
|
|
|
endfunc
|
|
|
|
|
|
2020-11-29 18:50:57 -07:00
|
|
|
|
" Test for updating the quickfix buffer whenever the associated quickfix list
|
|
|
|
|
" is changed.
|
|
|
|
|
func Xqfbuf_update(cchar)
|
|
|
|
|
call s:setup_commands(a:cchar)
|
|
|
|
|
|
|
|
|
|
Xexpr "F1:1:line1"
|
|
|
|
|
Xopen
|
|
|
|
|
call assert_equal(['F1|1| line1'], getline(1, '$'))
|
|
|
|
|
call assert_equal(1, g:Xgetlist({'changedtick' : 0}).changedtick)
|
|
|
|
|
|
|
|
|
|
" Test setqflist() using the 'lines' key in 'what'
|
|
|
|
|
" add a new entry
|
|
|
|
|
call g:Xsetlist([], 'a', {'lines' : ['F2:2: line2']})
|
|
|
|
|
call assert_equal(['F1|1| line1', 'F2|2| line2'], getline(1, '$'))
|
|
|
|
|
call assert_equal(2, g:Xgetlist({'changedtick' : 0}).changedtick)
|
|
|
|
|
" replace all the entries with a single entry
|
|
|
|
|
call g:Xsetlist([], 'r', {'lines' : ['F3:3: line3']})
|
|
|
|
|
call assert_equal(['F3|3| line3'], getline(1, '$'))
|
|
|
|
|
call assert_equal(3, g:Xgetlist({'changedtick' : 0}).changedtick)
|
|
|
|
|
" remove all the entries
|
|
|
|
|
call g:Xsetlist([], 'r', {'lines' : []})
|
|
|
|
|
call assert_equal([''], getline(1, '$'))
|
|
|
|
|
call assert_equal(4, g:Xgetlist({'changedtick' : 0}).changedtick)
|
|
|
|
|
" add a new list
|
|
|
|
|
call g:Xsetlist([], ' ', {'lines' : ['F4:4: line4']})
|
|
|
|
|
call assert_equal(['F4|4| line4'], getline(1, '$'))
|
|
|
|
|
call assert_equal(1, g:Xgetlist({'changedtick' : 0}).changedtick)
|
|
|
|
|
|
|
|
|
|
" Test setqflist() using the 'items' key in 'what'
|
|
|
|
|
" add a new entry
|
|
|
|
|
call g:Xsetlist([], 'a', {'items' : [{'filename' : 'F5', 'lnum' : 5, 'text' : 'line5'}]})
|
|
|
|
|
call assert_equal(['F4|4| line4', 'F5|5| line5'], getline(1, '$'))
|
|
|
|
|
call assert_equal(2, g:Xgetlist({'changedtick' : 0}).changedtick)
|
|
|
|
|
" replace all the entries with a single entry
|
|
|
|
|
call g:Xsetlist([], 'r', {'items' : [{'filename' : 'F6', 'lnum' : 6, 'text' : 'line6'}]})
|
|
|
|
|
call assert_equal(['F6|6| line6'], getline(1, '$'))
|
|
|
|
|
call assert_equal(3, g:Xgetlist({'changedtick' : 0}).changedtick)
|
|
|
|
|
" remove all the entries
|
|
|
|
|
call g:Xsetlist([], 'r', {'items' : []})
|
|
|
|
|
call assert_equal([''], getline(1, '$'))
|
|
|
|
|
call assert_equal(4, g:Xgetlist({'changedtick' : 0}).changedtick)
|
|
|
|
|
" add a new list
|
|
|
|
|
call g:Xsetlist([], ' ', {'items' : [{'filename' : 'F7', 'lnum' : 7, 'text' : 'line7'}]})
|
|
|
|
|
call assert_equal(['F7|7| line7'], getline(1, '$'))
|
|
|
|
|
call assert_equal(1, g:Xgetlist({'changedtick' : 0}).changedtick)
|
|
|
|
|
|
|
|
|
|
call g:Xsetlist([], ' ', {})
|
|
|
|
|
call assert_equal([''], getline(1, '$'))
|
|
|
|
|
call assert_equal(1, g:Xgetlist({'changedtick' : 0}).changedtick)
|
|
|
|
|
|
|
|
|
|
Xclose
|
|
|
|
|
endfunc
|
|
|
|
|
|
|
|
|
|
func Test_qfbuf_update()
|
|
|
|
|
call Xqfbuf_update('c')
|
|
|
|
|
call Xqfbuf_update('l')
|
|
|
|
|
endfunc
|
|
|
|
|
|
2022-01-01 16:06:09 -07:00
|
|
|
|
" Test for the :vimgrep 'f' flag (fuzzy match)
|
|
|
|
|
func Xvimgrep_fuzzy_match(cchar)
|
|
|
|
|
call s:setup_commands(a:cchar)
|
|
|
|
|
|
|
|
|
|
Xvimgrep /three one/f Xfile*
|
|
|
|
|
let l = g:Xgetlist()
|
|
|
|
|
call assert_equal(2, len(l))
|
|
|
|
|
call assert_equal(['Xfile1', 1, 9, 'one two three'],
|
|
|
|
|
\ [bufname(l[0].bufnr), l[0].lnum, l[0].col, l[0].text])
|
|
|
|
|
call assert_equal(['Xfile2', 2, 1, 'three one two'],
|
|
|
|
|
\ [bufname(l[1].bufnr), l[1].lnum, l[1].col, l[1].text])
|
|
|
|
|
|
|
|
|
|
Xvimgrep /the/f Xfile*
|
|
|
|
|
let l = g:Xgetlist()
|
|
|
|
|
call assert_equal(3, len(l))
|
|
|
|
|
call assert_equal(['Xfile1', 1, 9, 'one two three'],
|
|
|
|
|
\ [bufname(l[0].bufnr), l[0].lnum, l[0].col, l[0].text])
|
|
|
|
|
call assert_equal(['Xfile2', 2, 1, 'three one two'],
|
|
|
|
|
\ [bufname(l[1].bufnr), l[1].lnum, l[1].col, l[1].text])
|
|
|
|
|
call assert_equal(['Xfile2', 4, 4, 'aaathreeaaa'],
|
|
|
|
|
\ [bufname(l[2].bufnr), l[2].lnum, l[2].col, l[2].text])
|
|
|
|
|
|
|
|
|
|
Xvimgrep /aaa/fg Xfile*
|
|
|
|
|
let l = g:Xgetlist()
|
|
|
|
|
call assert_equal(4, len(l))
|
|
|
|
|
call assert_equal(['Xfile1', 2, 1, 'aaaaaa'],
|
|
|
|
|
\ [bufname(l[0].bufnr), l[0].lnum, l[0].col, l[0].text])
|
|
|
|
|
call assert_equal(['Xfile1', 2, 4, 'aaaaaa'],
|
|
|
|
|
\ [bufname(l[1].bufnr), l[1].lnum, l[1].col, l[1].text])
|
|
|
|
|
call assert_equal(['Xfile2', 4, 1, 'aaathreeaaa'],
|
|
|
|
|
\ [bufname(l[2].bufnr), l[2].lnum, l[2].col, l[2].text])
|
|
|
|
|
call assert_equal(['Xfile2', 4, 9, 'aaathreeaaa'],
|
|
|
|
|
\ [bufname(l[3].bufnr), l[3].lnum, l[3].col, l[3].text])
|
|
|
|
|
|
|
|
|
|
call assert_fails('Xvimgrep /xyz/fg Xfile*', 'E480:')
|
|
|
|
|
endfunc
|
|
|
|
|
|
|
|
|
|
func Test_vimgrep_fuzzy_match()
|
|
|
|
|
call writefile(['one two three', 'aaaaaa'], 'Xfile1')
|
|
|
|
|
call writefile(['one', 'three one two', 'two', 'aaathreeaaa'], 'Xfile2')
|
|
|
|
|
call Xvimgrep_fuzzy_match('c')
|
|
|
|
|
call Xvimgrep_fuzzy_match('l')
|
|
|
|
|
call delete('Xfile1')
|
|
|
|
|
call delete('Xfile2')
|
|
|
|
|
endfunc
|
|
|
|
|
|
2021-05-03 09:05:45 -07:00
|
|
|
|
" Test for getting a specific item from a quickfix list
|
|
|
|
|
func Xtest_getqflist_by_idx(cchar)
|
|
|
|
|
call s:setup_commands(a:cchar)
|
|
|
|
|
" Empty list
|
|
|
|
|
call assert_equal([], g:Xgetlist({'idx' : 1, 'items' : 0}).items)
|
|
|
|
|
Xexpr ['F1:10:L10', 'F1:20:L20']
|
|
|
|
|
let l = g:Xgetlist({'idx' : 2, 'items' : 0}).items
|
|
|
|
|
call assert_equal(bufnr('F1'), l[0].bufnr)
|
|
|
|
|
call assert_equal(20, l[0].lnum)
|
|
|
|
|
call assert_equal('L20', l[0].text)
|
|
|
|
|
call assert_equal([], g:Xgetlist({'idx' : -1, 'items' : 0}).items)
|
|
|
|
|
call assert_equal([], g:Xgetlist({'idx' : 3, 'items' : 0}).items)
|
2022-10-12 19:13:17 -07:00
|
|
|
|
call assert_equal({}, g:Xgetlist(#{idx: "abc"}))
|
2021-05-03 09:05:45 -07:00
|
|
|
|
%bwipe!
|
|
|
|
|
endfunc
|
|
|
|
|
|
|
|
|
|
func Test_getqflist_by_idx()
|
|
|
|
|
call Xtest_getqflist_by_idx('c')
|
|
|
|
|
call Xtest_getqflist_by_idx('l')
|
|
|
|
|
endfunc
|
|
|
|
|
|
|
|
|
|
" Test for the 'quickfixtextfunc' setting
|
|
|
|
|
func Tqfexpr(info)
|
|
|
|
|
if a:info.quickfix
|
2021-05-03 22:57:00 -07:00
|
|
|
|
let qfl = getqflist({'id' : a:info.id, 'items' : 1}).items
|
2021-05-03 09:05:45 -07:00
|
|
|
|
else
|
2021-05-03 22:57:00 -07:00
|
|
|
|
let qfl = getloclist(a:info.winid, {'id' : a:info.id, 'items' : 1}).items
|
2021-05-03 09:05:45 -07:00
|
|
|
|
endif
|
|
|
|
|
|
|
|
|
|
|
2021-05-03 22:57:00 -07:00
|
|
|
|
let l = []
|
|
|
|
|
for idx in range(a:info.start_idx - 1, a:info.end_idx - 1)
|
|
|
|
|
let e = qfl[idx]
|
|
|
|
|
let s = ''
|
|
|
|
|
if e.bufnr != 0
|
|
|
|
|
let bname = bufname(e.bufnr)
|
|
|
|
|
let s ..= fnamemodify(bname, ':.')
|
|
|
|
|
endif
|
|
|
|
|
let s ..= '-'
|
|
|
|
|
let s ..= 'L' .. string(e.lnum) .. 'C' .. string(e.col) .. '-'
|
|
|
|
|
let s ..= e.text
|
|
|
|
|
call add(l, s)
|
|
|
|
|
endfor
|
|
|
|
|
|
|
|
|
|
return l
|
2021-05-03 09:05:45 -07:00
|
|
|
|
endfunc
|
|
|
|
|
|
|
|
|
|
func Xtest_qftextfunc(cchar)
|
|
|
|
|
call s:setup_commands(a:cchar)
|
|
|
|
|
|
|
|
|
|
set efm=%f:%l:%c:%m
|
|
|
|
|
set quickfixtextfunc=Tqfexpr
|
2021-06-22 19:02:59 -07:00
|
|
|
|
call assert_equal('Tqfexpr', &quickfixtextfunc)
|
|
|
|
|
call assert_equal('',
|
|
|
|
|
\ g:Xgetlist({'quickfixtextfunc' : 1}).quickfixtextfunc)
|
2021-07-31 10:10:44 -07:00
|
|
|
|
call g:Xsetlist([
|
|
|
|
|
\ { 'filename': 'F1', 'lnum': 10, 'col': 2,
|
|
|
|
|
\ 'end_col': 7, 'text': 'green'},
|
|
|
|
|
\ { 'filename': 'F1', 'lnum': 20, 'end_lnum': 25, 'col': 4,
|
|
|
|
|
\ 'end_col': 8, 'text': 'blue'},
|
|
|
|
|
\ ])
|
|
|
|
|
|
2021-05-03 09:05:45 -07:00
|
|
|
|
Xwindow
|
|
|
|
|
call assert_equal('F1-L10C2-green', getline(1))
|
|
|
|
|
call assert_equal('F1-L20C4-blue', getline(2))
|
|
|
|
|
Xclose
|
|
|
|
|
set quickfixtextfunc&vim
|
|
|
|
|
Xwindow
|
2021-07-31 10:10:44 -07:00
|
|
|
|
call assert_equal('F1|10 col 2-7| green', getline(1))
|
|
|
|
|
call assert_equal('F1|20-25 col 4-8| blue', getline(2))
|
2021-05-03 09:05:45 -07:00
|
|
|
|
Xclose
|
2022-10-12 19:13:17 -07:00
|
|
|
|
|
|
|
|
|
set efm=%f:%l:%c:%m
|
|
|
|
|
set quickfixtextfunc=Tqfexpr
|
|
|
|
|
" Update the list with only the cwindow
|
|
|
|
|
Xwindow
|
|
|
|
|
only
|
|
|
|
|
call g:Xsetlist([
|
|
|
|
|
\ { 'filename': 'F2', 'lnum': 20, 'col': 2,
|
|
|
|
|
\ 'end_col': 7, 'text': 'red'}
|
|
|
|
|
\ ])
|
|
|
|
|
call assert_equal(['F2-L20C2-red'], getline(1, '$'))
|
|
|
|
|
new
|
|
|
|
|
Xclose
|
2021-05-03 09:05:45 -07:00
|
|
|
|
set efm&
|
|
|
|
|
set quickfixtextfunc&
|
|
|
|
|
|
|
|
|
|
" Test for per list 'quickfixtextfunc' setting
|
|
|
|
|
func PerQfText(info)
|
|
|
|
|
if a:info.quickfix
|
2021-05-03 22:57:00 -07:00
|
|
|
|
let qfl = getqflist({'id' : a:info.id, 'items' : 1}).items
|
2021-05-03 09:05:45 -07:00
|
|
|
|
else
|
2021-05-03 22:57:00 -07:00
|
|
|
|
let qfl = getloclist(a:info.winid, {'id' : a:info.id, 'items' : 1}).items
|
2021-05-03 09:05:45 -07:00
|
|
|
|
endif
|
|
|
|
|
if empty(qfl)
|
2021-05-03 22:57:00 -07:00
|
|
|
|
return []
|
2021-05-03 09:05:45 -07:00
|
|
|
|
endif
|
2021-05-03 22:57:00 -07:00
|
|
|
|
let l = []
|
|
|
|
|
for idx in range(a:info.start_idx - 1, a:info.end_idx - 1)
|
|
|
|
|
call add(l, 'Line ' .. qfl[idx].lnum .. ', Col ' .. qfl[idx].col)
|
|
|
|
|
endfor
|
|
|
|
|
return l
|
2021-05-03 09:05:45 -07:00
|
|
|
|
endfunc
|
|
|
|
|
set quickfixtextfunc=Tqfexpr
|
|
|
|
|
call g:Xsetlist([], ' ', {'quickfixtextfunc' : "PerQfText"})
|
|
|
|
|
Xaddexpr ['F1:10:2:green', 'F1:20:4:blue']
|
|
|
|
|
Xwindow
|
|
|
|
|
call assert_equal('Line 10, Col 2', getline(1))
|
|
|
|
|
call assert_equal('Line 20, Col 4', getline(2))
|
|
|
|
|
Xclose
|
2021-06-22 19:02:59 -07:00
|
|
|
|
call assert_equal(function('PerQfText'),
|
|
|
|
|
\ g:Xgetlist({'quickfixtextfunc' : 1}).quickfixtextfunc)
|
2021-05-03 22:55:38 -07:00
|
|
|
|
" Add entries to the list when the quickfix buffer is hidden
|
|
|
|
|
Xaddexpr ['F1:30:6:red']
|
|
|
|
|
Xwindow
|
|
|
|
|
call assert_equal('Line 30, Col 6', getline(3))
|
|
|
|
|
Xclose
|
2021-05-03 09:05:45 -07:00
|
|
|
|
call g:Xsetlist([], 'r', {'quickfixtextfunc' : ''})
|
2021-06-22 19:02:59 -07:00
|
|
|
|
call assert_equal('', g:Xgetlist({'quickfixtextfunc' : 1}).quickfixtextfunc)
|
2021-05-03 09:05:45 -07:00
|
|
|
|
set quickfixtextfunc&
|
|
|
|
|
delfunc PerQfText
|
|
|
|
|
|
|
|
|
|
" Non-existing function
|
|
|
|
|
set quickfixtextfunc=Tabc
|
2020-10-10 10:11:34 -07:00
|
|
|
|
call assert_fails("Xexpr ['F1:10:2:green', 'F1:20:4:blue']", 'E117:')
|
2021-05-03 09:05:45 -07:00
|
|
|
|
call assert_fails("Xwindow", 'E117:')
|
|
|
|
|
Xclose
|
|
|
|
|
set quickfixtextfunc&
|
|
|
|
|
|
|
|
|
|
" set option to a non-function
|
|
|
|
|
set quickfixtextfunc=[10,\ 20]
|
2020-10-10 10:11:34 -07:00
|
|
|
|
call assert_fails("Xexpr ['F1:10:2:green', 'F1:20:4:blue']", 'E117:')
|
2021-05-03 09:05:45 -07:00
|
|
|
|
call assert_fails("Xwindow", 'E117:')
|
|
|
|
|
Xclose
|
|
|
|
|
set quickfixtextfunc&
|
|
|
|
|
|
|
|
|
|
" set option to a function with different set of arguments
|
|
|
|
|
func Xqftext(a, b, c)
|
|
|
|
|
return a:a .. a:b .. a:c
|
|
|
|
|
endfunc
|
|
|
|
|
set quickfixtextfunc=Xqftext
|
2020-10-10 10:11:34 -07:00
|
|
|
|
call assert_fails("Xexpr ['F1:10:2:green', 'F1:20:4:blue']", 'E119:')
|
2021-05-03 09:05:45 -07:00
|
|
|
|
call assert_fails("Xwindow", 'E119:')
|
|
|
|
|
Xclose
|
2021-05-03 22:57:00 -07:00
|
|
|
|
|
|
|
|
|
" set option to a function that returns a list with non-strings
|
|
|
|
|
func Xqftext2(d)
|
|
|
|
|
return ['one', [], 'two']
|
|
|
|
|
endfunc
|
|
|
|
|
set quickfixtextfunc=Xqftext2
|
2020-10-10 10:11:34 -07:00
|
|
|
|
call assert_fails("Xexpr ['F1:10:2:green', 'F1:20:4:blue', 'F1:30:6:red']",
|
|
|
|
|
\ 'E730:')
|
2021-05-03 22:57:00 -07:00
|
|
|
|
call assert_fails('Xwindow', 'E730:')
|
2021-06-22 19:02:59 -07:00
|
|
|
|
call assert_equal(['one', 'F1|20 col 4| blue', 'F1|30 col 6| red'],
|
|
|
|
|
\ getline(1, '$'))
|
2021-05-03 22:57:00 -07:00
|
|
|
|
Xclose
|
|
|
|
|
|
2021-05-03 09:05:45 -07:00
|
|
|
|
set quickfixtextfunc&
|
|
|
|
|
delfunc Xqftext
|
2021-05-03 22:57:00 -07:00
|
|
|
|
delfunc Xqftext2
|
2021-06-22 19:02:59 -07:00
|
|
|
|
|
|
|
|
|
" set the global option to a lambda function
|
|
|
|
|
set quickfixtextfunc={d\ ->\ map(g:Xgetlist({'id'\ :\ d.id,\ 'items'\ :\ 1}).items[d.start_idx-1:d.end_idx-1],\ 'v:val.text')}
|
|
|
|
|
Xexpr ['F1:10:2:green', 'F1:20:4:blue']
|
|
|
|
|
Xwindow
|
|
|
|
|
call assert_equal(['green', 'blue'], getline(1, '$'))
|
|
|
|
|
Xclose
|
|
|
|
|
call assert_equal("{d -> map(g:Xgetlist({'id' : d.id, 'items' : 1}).items[d.start_idx-1:d.end_idx-1], 'v:val.text')}", &quickfixtextfunc)
|
|
|
|
|
set quickfixtextfunc&
|
|
|
|
|
|
|
|
|
|
" use a lambda function that returns an empty list
|
|
|
|
|
set quickfixtextfunc={d\ ->\ []}
|
|
|
|
|
Xexpr ['F1:10:2:green', 'F1:20:4:blue']
|
|
|
|
|
Xwindow
|
|
|
|
|
call assert_equal(['F1|10 col 2| green', 'F1|20 col 4| blue'],
|
|
|
|
|
\ getline(1, '$'))
|
|
|
|
|
Xclose
|
|
|
|
|
set quickfixtextfunc&
|
|
|
|
|
|
|
|
|
|
" use a lambda function that returns a list with empty strings
|
|
|
|
|
set quickfixtextfunc={d\ ->\ ['',\ '']}
|
|
|
|
|
Xexpr ['F1:10:2:green', 'F1:20:4:blue']
|
|
|
|
|
Xwindow
|
|
|
|
|
call assert_equal(['F1|10 col 2| green', 'F1|20 col 4| blue'],
|
|
|
|
|
\ getline(1, '$'))
|
|
|
|
|
Xclose
|
|
|
|
|
set quickfixtextfunc&
|
|
|
|
|
|
|
|
|
|
" set the per-quickfix list text function to a lambda function
|
|
|
|
|
call g:Xsetlist([], ' ',
|
|
|
|
|
\ {'quickfixtextfunc' :
|
|
|
|
|
\ {d -> map(g:Xgetlist({'id' : d.id, 'items' : 1}).items[d.start_idx-1:d.end_idx-1],
|
|
|
|
|
\ "'Line ' .. v:val.lnum .. ', Col ' .. v:val.col")}})
|
|
|
|
|
Xaddexpr ['F1:10:2:green', 'F1:20:4:blue']
|
|
|
|
|
Xwindow
|
|
|
|
|
call assert_equal('Line 10, Col 2', getline(1))
|
|
|
|
|
call assert_equal('Line 20, Col 4', getline(2))
|
|
|
|
|
Xclose
|
|
|
|
|
call assert_match("function('<lambda>\\d\\+')", string(g:Xgetlist({'quickfixtextfunc' : 1}).quickfixtextfunc))
|
|
|
|
|
call g:Xsetlist([], 'f')
|
2021-05-03 09:05:45 -07:00
|
|
|
|
endfunc
|
|
|
|
|
|
|
|
|
|
func Test_qftextfunc()
|
|
|
|
|
call Xtest_qftextfunc('c')
|
|
|
|
|
call Xtest_qftextfunc('l')
|
|
|
|
|
endfunc
|
|
|
|
|
|
2022-11-06 22:37:22 -07:00
|
|
|
|
func Test_qftextfunc_callback()
|
|
|
|
|
let lines =<< trim END
|
|
|
|
|
set efm=%f:%l:%c:%m
|
|
|
|
|
|
2022-11-06 23:08:29 -07:00
|
|
|
|
#" Test for using a function name
|
|
|
|
|
LET &qftf = 'g:Tqfexpr'
|
|
|
|
|
cexpr "F0:0:0:L0"
|
|
|
|
|
copen
|
|
|
|
|
call assert_equal('F0-L0C0-L0', getline(1))
|
|
|
|
|
cclose
|
|
|
|
|
|
2022-11-06 22:37:22 -07:00
|
|
|
|
#" Test for using a function()
|
|
|
|
|
set qftf=function('g:Tqfexpr')
|
|
|
|
|
cexpr "F1:1:1:L1"
|
|
|
|
|
copen
|
|
|
|
|
call assert_equal('F1-L1C1-L1', getline(1))
|
|
|
|
|
cclose
|
|
|
|
|
|
|
|
|
|
#" Using a funcref variable to set 'quickfixtextfunc'
|
|
|
|
|
VAR Fn = function('g:Tqfexpr')
|
|
|
|
|
LET &qftf = Fn
|
|
|
|
|
cexpr "F2:2:2:L2"
|
|
|
|
|
copen
|
|
|
|
|
call assert_equal('F2-L2C2-L2', getline(1))
|
|
|
|
|
cclose
|
|
|
|
|
|
|
|
|
|
#" Using string(funcref_variable) to set 'quickfixtextfunc'
|
|
|
|
|
LET Fn = function('g:Tqfexpr')
|
|
|
|
|
LET &qftf = string(Fn)
|
|
|
|
|
cexpr "F3:3:3:L3"
|
|
|
|
|
copen
|
|
|
|
|
call assert_equal('F3-L3C3-L3', getline(1))
|
|
|
|
|
cclose
|
|
|
|
|
|
|
|
|
|
#" Test for using a funcref()
|
|
|
|
|
set qftf=funcref('g:Tqfexpr')
|
|
|
|
|
cexpr "F4:4:4:L4"
|
|
|
|
|
copen
|
|
|
|
|
call assert_equal('F4-L4C4-L4', getline(1))
|
|
|
|
|
cclose
|
|
|
|
|
|
|
|
|
|
#" Using a funcref variable to set 'quickfixtextfunc'
|
|
|
|
|
LET Fn = funcref('g:Tqfexpr')
|
|
|
|
|
LET &qftf = Fn
|
|
|
|
|
cexpr "F5:5:5:L5"
|
|
|
|
|
copen
|
|
|
|
|
call assert_equal('F5-L5C5-L5', getline(1))
|
|
|
|
|
cclose
|
|
|
|
|
|
|
|
|
|
#" Using a string(funcref_variable) to set 'quickfixtextfunc'
|
|
|
|
|
LET Fn = funcref('g:Tqfexpr')
|
|
|
|
|
LET &qftf = string(Fn)
|
|
|
|
|
cexpr "F5:5:5:L5"
|
|
|
|
|
copen
|
|
|
|
|
call assert_equal('F5-L5C5-L5', getline(1))
|
|
|
|
|
cclose
|
|
|
|
|
|
|
|
|
|
#" Test for using a lambda function with set
|
|
|
|
|
VAR optval = "LSTART a LMIDDLE Tqfexpr(a) LEND"
|
|
|
|
|
LET optval = substitute(optval, ' ', '\\ ', 'g')
|
|
|
|
|
exe "set qftf=" .. optval
|
|
|
|
|
cexpr "F6:6:6:L6"
|
|
|
|
|
copen
|
|
|
|
|
call assert_equal('F6-L6C6-L6', getline(1))
|
|
|
|
|
cclose
|
|
|
|
|
|
|
|
|
|
#" Set 'quickfixtextfunc' to a lambda expression
|
|
|
|
|
LET &qftf = LSTART a LMIDDLE Tqfexpr(a) LEND
|
|
|
|
|
cexpr "F7:7:7:L7"
|
|
|
|
|
copen
|
|
|
|
|
call assert_equal('F7-L7C7-L7', getline(1))
|
|
|
|
|
cclose
|
|
|
|
|
|
|
|
|
|
#" Set 'quickfixtextfunc' to string(lambda_expression)
|
|
|
|
|
LET &qftf = "LSTART a LMIDDLE Tqfexpr(a) LEND"
|
|
|
|
|
cexpr "F8:8:8:L8"
|
|
|
|
|
copen
|
|
|
|
|
call assert_equal('F8-L8C8-L8', getline(1))
|
|
|
|
|
cclose
|
|
|
|
|
|
|
|
|
|
#" Set 'quickfixtextfunc' to a variable with a lambda expression
|
|
|
|
|
VAR Lambda = LSTART a LMIDDLE Tqfexpr(a) LEND
|
|
|
|
|
LET &qftf = Lambda
|
|
|
|
|
cexpr "F9:9:9:L9"
|
|
|
|
|
copen
|
|
|
|
|
call assert_equal('F9-L9C9-L9', getline(1))
|
|
|
|
|
cclose
|
|
|
|
|
|
|
|
|
|
#" Set 'quickfixtextfunc' to a string(variable with a lambda expression)
|
|
|
|
|
LET Lambda = LSTART a LMIDDLE Tqfexpr(a) LEND
|
|
|
|
|
LET &qftf = string(Lambda)
|
|
|
|
|
cexpr "F9:9:9:L9"
|
|
|
|
|
copen
|
|
|
|
|
call assert_equal('F9-L9C9-L9', getline(1))
|
|
|
|
|
cclose
|
|
|
|
|
END
|
|
|
|
|
call CheckLegacyAndVim9Success(lines)
|
|
|
|
|
|
2022-12-02 05:47:52 -07:00
|
|
|
|
" Test for using a script-local function name
|
|
|
|
|
func s:TqfFunc2(info)
|
|
|
|
|
let g:TqfFunc2Args = [a:info.start_idx, a:info.end_idx]
|
|
|
|
|
return ''
|
|
|
|
|
endfunc
|
|
|
|
|
let g:TqfFunc2Args = []
|
|
|
|
|
set quickfixtextfunc=s:TqfFunc2
|
|
|
|
|
cexpr "F10:10:10:L10"
|
|
|
|
|
cclose
|
|
|
|
|
call assert_equal([1, 1], g:TqfFunc2Args)
|
|
|
|
|
|
|
|
|
|
let &quickfixtextfunc = 's:TqfFunc2'
|
|
|
|
|
cexpr "F11:11:11:L11"
|
|
|
|
|
cclose
|
|
|
|
|
call assert_equal([1, 1], g:TqfFunc2Args)
|
|
|
|
|
delfunc s:TqfFunc2
|
|
|
|
|
|
2022-11-06 22:37:22 -07:00
|
|
|
|
" set 'quickfixtextfunc' to a partial with dict. This used to cause a crash.
|
|
|
|
|
func SetQftfFunc()
|
|
|
|
|
let params = {'qftf': function('g:DictQftfFunc')}
|
|
|
|
|
let &quickfixtextfunc = params.qftf
|
|
|
|
|
endfunc
|
|
|
|
|
func g:DictQftfFunc(_) dict
|
|
|
|
|
endfunc
|
|
|
|
|
call SetQftfFunc()
|
|
|
|
|
new
|
|
|
|
|
call SetQftfFunc()
|
|
|
|
|
bw
|
|
|
|
|
call test_garbagecollect_now()
|
|
|
|
|
new
|
|
|
|
|
set qftf=
|
|
|
|
|
wincmd w
|
|
|
|
|
set qftf=
|
|
|
|
|
:%bw!
|
|
|
|
|
|
|
|
|
|
" set per-quickfix list 'quickfixtextfunc' to a partial with dict. This used
|
|
|
|
|
" to cause a crash.
|
|
|
|
|
let &qftf = ''
|
|
|
|
|
func SetLocalQftfFunc()
|
|
|
|
|
let params = {'qftf': function('g:DictQftfFunc')}
|
|
|
|
|
call setqflist([], 'a', {'quickfixtextfunc' : params.qftf})
|
|
|
|
|
endfunc
|
|
|
|
|
call SetLocalQftfFunc()
|
|
|
|
|
call test_garbagecollect_now()
|
|
|
|
|
call setqflist([], 'a', {'quickfixtextfunc' : ''})
|
|
|
|
|
delfunc g:DictQftfFunc
|
|
|
|
|
delfunc SetQftfFunc
|
|
|
|
|
delfunc SetLocalQftfFunc
|
|
|
|
|
set efm&
|
|
|
|
|
endfunc
|
|
|
|
|
|
2021-06-26 07:44:05 -07:00
|
|
|
|
" Test for updating a location list for some other window and check that
|
|
|
|
|
" 'qftextfunc' uses the correct location list.
|
|
|
|
|
func Test_qftextfunc_other_loclist()
|
|
|
|
|
%bw!
|
|
|
|
|
call setloclist(0, [], 'f')
|
|
|
|
|
|
|
|
|
|
" create a window and a location list for it and open the location list
|
|
|
|
|
" window
|
|
|
|
|
lexpr ['F1:10:12:one', 'F1:20:14:two']
|
|
|
|
|
let w1_id = win_getid()
|
|
|
|
|
call setloclist(0, [], ' ',
|
|
|
|
|
\ {'lines': ['F1:10:12:one', 'F1:20:14:two'],
|
|
|
|
|
\ 'quickfixtextfunc':
|
|
|
|
|
\ {d -> map(getloclist(d.winid, {'id' : d.id,
|
|
|
|
|
\ 'items' : 1}).items[d.start_idx-1:d.end_idx-1],
|
|
|
|
|
\ "'Line ' .. v:val.lnum .. ', Col ' .. v:val.col")}})
|
|
|
|
|
lwindow
|
|
|
|
|
let w2_id = win_getid()
|
|
|
|
|
|
|
|
|
|
" create another window and a location list for it and open the location
|
|
|
|
|
" list window
|
|
|
|
|
topleft new
|
|
|
|
|
let w3_id = win_getid()
|
|
|
|
|
call setloclist(0, [], ' ',
|
|
|
|
|
\ {'lines': ['F2:30:32:eleven', 'F2:40:34:twelve'],
|
|
|
|
|
\ 'quickfixtextfunc':
|
|
|
|
|
\ {d -> map(getloclist(d.winid, {'id' : d.id,
|
|
|
|
|
\ 'items' : 1}).items[d.start_idx-1:d.end_idx-1],
|
|
|
|
|
\ "'Ligne ' .. v:val.lnum .. ', Colonne ' .. v:val.col")}})
|
|
|
|
|
lwindow
|
|
|
|
|
let w4_id = win_getid()
|
|
|
|
|
|
|
|
|
|
topleft new
|
|
|
|
|
lexpr ['F3:50:52:green', 'F3:60:54:blue']
|
|
|
|
|
let w5_id = win_getid()
|
|
|
|
|
|
|
|
|
|
" change the location list for some other window
|
|
|
|
|
call setloclist(0, [], 'r', {'lines': ['F3:55:56:aaa', 'F3:57:58:bbb']})
|
|
|
|
|
call setloclist(w1_id, [], 'r', {'lines': ['F1:62:63:bbb', 'F1:64:65:ccc']})
|
|
|
|
|
call setloclist(w3_id, [], 'r', {'lines': ['F2:76:77:ddd', 'F2:78:79:eee']})
|
|
|
|
|
call assert_equal(['Line 62, Col 63', 'Line 64, Col 65'],
|
|
|
|
|
\ getbufline(winbufnr(w2_id), 1, '$'))
|
|
|
|
|
call assert_equal(['Ligne 76, Colonne 77', 'Ligne 78, Colonne 79'],
|
|
|
|
|
\ getbufline(winbufnr(w4_id), 1, '$'))
|
|
|
|
|
call setloclist(w2_id, [], 'r', {'lines': ['F1:32:33:fff', 'F1:34:35:ggg']})
|
|
|
|
|
call setloclist(w4_id, [], 'r', {'lines': ['F2:46:47:hhh', 'F2:48:49:jjj']})
|
|
|
|
|
call assert_equal(['Line 32, Col 33', 'Line 34, Col 35'],
|
|
|
|
|
\ getbufline(winbufnr(w2_id), 1, '$'))
|
|
|
|
|
call assert_equal(['Ligne 46, Colonne 47', 'Ligne 48, Colonne 49'],
|
|
|
|
|
\ getbufline(winbufnr(w4_id), 1, '$'))
|
|
|
|
|
|
|
|
|
|
call win_gotoid(w5_id)
|
|
|
|
|
lwindow
|
|
|
|
|
call assert_equal(['F3|55 col 56| aaa', 'F3|57 col 58| bbb'],
|
|
|
|
|
\ getline(1, '$'))
|
|
|
|
|
%bw!
|
|
|
|
|
endfunc
|
|
|
|
|
|
2021-07-31 11:16:22 -07:00
|
|
|
|
func Test_locationlist_open_in_newtab()
|
|
|
|
|
call s:create_test_file('Xqftestfile1')
|
|
|
|
|
call s:create_test_file('Xqftestfile2')
|
|
|
|
|
call s:create_test_file('Xqftestfile3')
|
|
|
|
|
|
|
|
|
|
%bwipe!
|
|
|
|
|
|
2022-10-12 23:31:10 -07:00
|
|
|
|
let lines =<< trim END
|
|
|
|
|
Xqftestfile1:5:Line5
|
|
|
|
|
Xqftestfile2:10:Line10
|
|
|
|
|
Xqftestfile3:16:Line16
|
|
|
|
|
END
|
|
|
|
|
lgetexpr lines
|
2021-07-31 11:16:22 -07:00
|
|
|
|
|
|
|
|
|
silent! llast
|
|
|
|
|
call assert_equal(1, tabpagenr('$'))
|
|
|
|
|
call assert_equal('Xqftestfile3', bufname())
|
|
|
|
|
|
|
|
|
|
set switchbuf=newtab
|
|
|
|
|
|
|
|
|
|
silent! lfirst
|
|
|
|
|
call assert_equal(2, tabpagenr('$'))
|
|
|
|
|
call assert_equal('Xqftestfile1', bufname())
|
|
|
|
|
|
|
|
|
|
silent! lnext
|
|
|
|
|
call assert_equal(3, tabpagenr('$'))
|
|
|
|
|
call assert_equal('Xqftestfile2', bufname())
|
|
|
|
|
|
|
|
|
|
call delete('Xqftestfile1')
|
|
|
|
|
call delete('Xqftestfile2')
|
|
|
|
|
call delete('Xqftestfile3')
|
|
|
|
|
set switchbuf&vim
|
|
|
|
|
|
|
|
|
|
%bwipe!
|
|
|
|
|
endfunc
|
|
|
|
|
|
2021-07-31 11:19:13 -07:00
|
|
|
|
" Test for win_gettype() in quickfix and location list windows
|
|
|
|
|
func Test_win_gettype()
|
|
|
|
|
copen
|
|
|
|
|
call assert_equal("quickfix", win_gettype())
|
|
|
|
|
let wid = win_getid()
|
|
|
|
|
wincmd p
|
|
|
|
|
call assert_equal("quickfix", win_gettype(wid))
|
|
|
|
|
cclose
|
|
|
|
|
lexpr ''
|
|
|
|
|
lopen
|
|
|
|
|
call assert_equal("loclist", win_gettype())
|
|
|
|
|
let wid = win_getid()
|
|
|
|
|
wincmd p
|
|
|
|
|
call assert_equal("loclist", win_gettype(wid))
|
|
|
|
|
lclose
|
|
|
|
|
endfunc
|
|
|
|
|
|
2022-11-05 14:02:57 -07:00
|
|
|
|
fun Test_vimgrep_nomatch()
|
|
|
|
|
call XexprTests('c')
|
|
|
|
|
call g:Xsetlist([{'lnum':10,'text':'Line1'}])
|
|
|
|
|
copen
|
|
|
|
|
if has("win32")
|
|
|
|
|
call assert_fails('vimgrep foo *.zzz', 'E479:')
|
|
|
|
|
let expected = [{'lnum': 10, 'bufnr': 0, 'end_lnum': 0, 'pattern': '', 'valid': 0, 'vcol': 0, 'nr': 0, 'module': '', 'type': '', 'end_col': 0, 'col': 0, 'text': 'Line1'}]
|
|
|
|
|
else
|
|
|
|
|
call assert_fails('vimgrep foo *.zzz', 'E480:')
|
|
|
|
|
let expected = []
|
|
|
|
|
endif
|
|
|
|
|
call assert_equal(expected, getqflist())
|
|
|
|
|
cclose
|
|
|
|
|
endfunc
|
|
|
|
|
|
2021-12-19 04:00:04 -07:00
|
|
|
|
" Test for opening the quickfix window in two tab pages and then closing one
|
|
|
|
|
" of the quickfix windows. This should not make the quickfix buffer unlisted.
|
|
|
|
|
" (github issue #9300).
|
|
|
|
|
func Test_two_qf_windows()
|
|
|
|
|
cexpr "F1:1:line1"
|
|
|
|
|
copen
|
|
|
|
|
tabnew
|
|
|
|
|
copen
|
|
|
|
|
call assert_true(&buflisted)
|
|
|
|
|
cclose
|
|
|
|
|
tabfirst
|
|
|
|
|
call assert_true(&buflisted)
|
|
|
|
|
let bnum = bufnr()
|
|
|
|
|
cclose
|
|
|
|
|
" if all the quickfix windows are closed, then buffer should be unlisted.
|
|
|
|
|
call assert_false(buflisted(bnum))
|
|
|
|
|
%bw!
|
|
|
|
|
|
|
|
|
|
" Repeat the test for a location list
|
|
|
|
|
lexpr "F2:2:line2"
|
|
|
|
|
lopen
|
|
|
|
|
let bnum = bufnr()
|
|
|
|
|
tabnew
|
|
|
|
|
exe "buffer" bnum
|
|
|
|
|
tabfirst
|
|
|
|
|
lclose
|
|
|
|
|
tablast
|
|
|
|
|
call assert_true(buflisted(bnum))
|
|
|
|
|
tabclose
|
|
|
|
|
lopen
|
|
|
|
|
call assert_true(buflisted(bnum))
|
|
|
|
|
lclose
|
|
|
|
|
call assert_false(buflisted(bnum))
|
|
|
|
|
%bw!
|
|
|
|
|
endfunc
|
|
|
|
|
|
2022-03-23 21:29:26 -07:00
|
|
|
|
" Weird sequence of commands that caused entering a wiped-out buffer
|
|
|
|
|
func Test_lopen_bwipe()
|
|
|
|
|
func R()
|
|
|
|
|
silent! tab lopen
|
|
|
|
|
e x
|
|
|
|
|
silent! lfile
|
|
|
|
|
endfunc
|
|
|
|
|
|
|
|
|
|
cal R()
|
|
|
|
|
cal R()
|
|
|
|
|
cal R()
|
|
|
|
|
bw!
|
|
|
|
|
delfunc R
|
|
|
|
|
endfunc
|
|
|
|
|
|
2022-03-23 21:39:31 -07:00
|
|
|
|
" Another sequence of commands that caused all buffers to be wiped out
|
|
|
|
|
func Test_lopen_bwipe_all()
|
|
|
|
|
let lines =<< trim END
|
|
|
|
|
func R()
|
|
|
|
|
silent! tab lopen
|
|
|
|
|
e foo
|
|
|
|
|
silent! lfile
|
|
|
|
|
endfunc
|
|
|
|
|
cal R()
|
|
|
|
|
exe "norm \<C-W>\<C-V>0"
|
|
|
|
|
cal R()
|
|
|
|
|
bwipe
|
|
|
|
|
|
|
|
|
|
call writefile(['done'], 'Xresult')
|
|
|
|
|
qall!
|
|
|
|
|
END
|
|
|
|
|
call writefile(lines, 'Xscript')
|
2022-12-08 03:58:06 -07:00
|
|
|
|
if RunVim([], [], '-u NONE -n -X -Z -e -m -s -S Xscript')
|
2022-03-23 21:39:31 -07:00
|
|
|
|
call assert_equal(['done'], readfile('Xresult'))
|
|
|
|
|
endif
|
|
|
|
|
|
|
|
|
|
call delete('Xscript')
|
|
|
|
|
call delete('Xresult')
|
|
|
|
|
endfunc
|
|
|
|
|
|
2022-10-12 19:13:17 -07:00
|
|
|
|
" Test for calling setqflist() function recursively
|
|
|
|
|
func Test_recursive_setqflist()
|
|
|
|
|
augroup QF_Test
|
|
|
|
|
au!
|
|
|
|
|
autocmd BufWinEnter quickfix call setqflist([], 'r')
|
|
|
|
|
augroup END
|
|
|
|
|
|
|
|
|
|
copen
|
|
|
|
|
call assert_fails("call setqflist([], 'a')", 'E952:')
|
|
|
|
|
|
|
|
|
|
augroup QF_Test
|
|
|
|
|
au!
|
|
|
|
|
augroup END
|
|
|
|
|
%bw!
|
|
|
|
|
endfunc
|
|
|
|
|
|
|
|
|
|
" Test for failure to create a new window when selecting a file from the
|
|
|
|
|
" quickfix window
|
|
|
|
|
func Test_cwindow_newwin_fails()
|
|
|
|
|
cgetexpr ["Xfile1:10:L10", "Xfile1:20:L20"]
|
|
|
|
|
cwindow
|
|
|
|
|
only
|
|
|
|
|
let qf_wid = win_getid()
|
|
|
|
|
" create the maximum number of scratch windows
|
|
|
|
|
let hor_win_count = (&lines - 1)/2
|
|
|
|
|
let hor_split_count = hor_win_count - 1
|
|
|
|
|
for s in range(1, hor_split_count) | new | set buftype=nofile | endfor
|
|
|
|
|
call win_gotoid(qf_wid)
|
|
|
|
|
call assert_fails('exe "normal \<CR>"', 'E36:')
|
|
|
|
|
%bw!
|
|
|
|
|
endfunc
|
|
|
|
|
|
|
|
|
|
" Test for updating the location list when only the location list window is
|
|
|
|
|
" present and the corresponding file window is closed.
|
|
|
|
|
func Test_loclist_update_with_llwin_only()
|
|
|
|
|
%bw!
|
|
|
|
|
new
|
|
|
|
|
wincmd w
|
|
|
|
|
lexpr ["Xfile1:1:Line1"]
|
|
|
|
|
lopen
|
|
|
|
|
wincmd p
|
|
|
|
|
close
|
|
|
|
|
call setloclist(2, [], 'r', {'lines': ["Xtest2:2:Line2"]})
|
|
|
|
|
call assert_equal(['Xtest2|2| Line2'], getbufline(winbufnr(2), 1, '$'))
|
|
|
|
|
%bw!
|
|
|
|
|
endfunc
|
|
|
|
|
|
|
|
|
|
" Test for getting the quickfix list after a buffer with an error is wiped out
|
|
|
|
|
func Test_getqflist_wiped_out_buffer()
|
|
|
|
|
%bw!
|
|
|
|
|
cexpr ["Xtest1:34:Wiped out"]
|
|
|
|
|
let bnum = bufnr('Xtest1')
|
|
|
|
|
call assert_equal(bnum, getqflist()[0].bufnr)
|
|
|
|
|
bw Xtest1
|
|
|
|
|
call assert_equal(0, getqflist()[0].bufnr)
|
|
|
|
|
%bw!
|
|
|
|
|
endfunc
|
2022-03-23 21:29:26 -07:00
|
|
|
|
|
2022-10-12 20:06:49 -07:00
|
|
|
|
" Test for the status message that is displayed when opening a new quickfix
|
|
|
|
|
" list
|
|
|
|
|
func Test_qflist_statusmsg()
|
|
|
|
|
cexpr "1\n2"
|
|
|
|
|
cexpr "1\n2\n3\ntest_quickfix.vim:1:msg"
|
|
|
|
|
call assert_equal('(4 of 4): msg', v:statusmsg)
|
|
|
|
|
call setqflist([], 'f')
|
|
|
|
|
%bw!
|
|
|
|
|
|
|
|
|
|
" When creating a new quickfix list, if an autocmd changes the quickfix list
|
|
|
|
|
" in the stack, then an error message should be displayed.
|
|
|
|
|
augroup QF_Test
|
|
|
|
|
au!
|
|
|
|
|
au BufEnter test_quickfix.vim colder
|
|
|
|
|
augroup END
|
|
|
|
|
cexpr "1\n2"
|
|
|
|
|
call assert_fails('cexpr "1\n2\n3\ntest_quickfix.vim:1:msg"', 'E925:')
|
|
|
|
|
call setqflist([], 'f')
|
|
|
|
|
augroup QF_Test
|
|
|
|
|
au!
|
|
|
|
|
augroup END
|
|
|
|
|
%bw!
|
|
|
|
|
|
|
|
|
|
augroup QF_Test
|
|
|
|
|
au!
|
|
|
|
|
au BufEnter test_quickfix.vim caddexpr "4"
|
|
|
|
|
augroup END
|
|
|
|
|
call assert_fails('cexpr "1\n2\n3\ntest_quickfix.vim:1:msg"', 'E925:')
|
|
|
|
|
call setqflist([], 'f')
|
|
|
|
|
augroup QF_Test
|
|
|
|
|
au!
|
|
|
|
|
augroup END
|
|
|
|
|
%bw!
|
|
|
|
|
endfunc
|
|
|
|
|
|
|
|
|
|
func Test_quickfixtextfunc_recursive()
|
|
|
|
|
func s:QFTfunc(o)
|
|
|
|
|
cgete '0'
|
|
|
|
|
endfunc
|
|
|
|
|
copen
|
|
|
|
|
let &quickfixtextfunc = 's:QFTfunc'
|
|
|
|
|
cex ""
|
|
|
|
|
|
|
|
|
|
let &quickfixtextfunc = ''
|
|
|
|
|
cclose
|
|
|
|
|
endfunc
|
|
|
|
|
|
2022-10-12 20:10:30 -07:00
|
|
|
|
" Test for replacing the location list from an autocmd. This used to cause a
|
|
|
|
|
" read from freed memory.
|
|
|
|
|
func Test_loclist_replace_autocmd()
|
|
|
|
|
%bw!
|
|
|
|
|
call setloclist(0, [], 'f')
|
|
|
|
|
let s:bufnr = bufnr()
|
|
|
|
|
cal setloclist(0, [{'0': 0, '': ''}])
|
|
|
|
|
au BufEnter * cal setloclist(1, [{'t': ''}, {'bufnr': s:bufnr}], 'r')
|
|
|
|
|
lopen
|
|
|
|
|
try
|
|
|
|
|
exe "norm j\<CR>"
|
|
|
|
|
catch
|
|
|
|
|
endtry
|
|
|
|
|
lnext
|
|
|
|
|
%bw!
|
|
|
|
|
call setloclist(0, [], 'f')
|
|
|
|
|
endfunc
|
2022-10-12 20:06:49 -07:00
|
|
|
|
|
2023-03-04 23:47:51 -07:00
|
|
|
|
" Test for a very long error line and a very long information line
|
|
|
|
|
func Test_very_long_error_line()
|
|
|
|
|
let msg = repeat('abcdefghijklmn', 146)
|
|
|
|
|
let emsg = 'Xlonglines.c:1:' . msg
|
|
|
|
|
call writefile([msg, emsg], 'Xerror', 'D')
|
|
|
|
|
cfile Xerror
|
|
|
|
|
cwindow
|
|
|
|
|
call assert_equal($'|| {msg}', getline(1))
|
|
|
|
|
call assert_equal($'Xlonglines.c|1| {msg}', getline(2))
|
|
|
|
|
cclose
|
|
|
|
|
|
|
|
|
|
let l = execute('clist!')->split("\n")
|
|
|
|
|
call assert_equal([$' 1: {msg}', $' 2 Xlonglines.c:1: {msg}'], l)
|
|
|
|
|
|
|
|
|
|
let l = execute('cc')->split("\n")
|
|
|
|
|
call assert_equal([$'(2 of 2): {msg}'], l)
|
|
|
|
|
|
|
|
|
|
call setqflist([], 'f')
|
|
|
|
|
endfunc
|
|
|
|
|
|
|
|
|
|
" In the quickfix window, spaces at the beginning of an informational line
|
|
|
|
|
" should not be removed but should be removed from an error line.
|
|
|
|
|
func Test_info_line_with_space()
|
|
|
|
|
cexpr ["a.c:20:12: error: expected ';' before ':' token",
|
|
|
|
|
\ ' 20 | Afunc():', '', ' | ^']
|
|
|
|
|
copen
|
|
|
|
|
call assert_equal(["a.c|20 col 12| error: expected ';' before ':' token",
|
|
|
|
|
\ '|| 20 | Afunc():', '|| ',
|
|
|
|
|
\ '|| | ^'], getline(1, '$'))
|
|
|
|
|
cclose
|
|
|
|
|
|
|
|
|
|
let l = execute('clist!')->split("\n")
|
|
|
|
|
call assert_equal([" 1 a.c:20 col 12: error: expected ';' before ':' token",
|
|
|
|
|
\ ' 2: 20 | Afunc():', ' 3: ', ' 4: | ^'], l)
|
|
|
|
|
|
|
|
|
|
call setqflist([], 'f')
|
|
|
|
|
endfunc
|
|
|
|
|
|
2022-12-02 12:44:37 -07:00
|
|
|
|
func s:QfTf(_)
|
|
|
|
|
endfunc
|
|
|
|
|
|
|
|
|
|
func Test_setqflist_cb_arg()
|
|
|
|
|
" This was changing the callback name in the dictionary.
|
|
|
|
|
let d = #{quickfixtextfunc: 's:QfTf'}
|
|
|
|
|
call setqflist([], 'a', d)
|
|
|
|
|
call assert_equal('s:QfTf', d.quickfixtextfunc)
|
|
|
|
|
|
|
|
|
|
call setqflist([], 'f')
|
|
|
|
|
endfunc
|
|
|
|
|
|
2023-05-27 07:15:22 -07:00
|
|
|
|
" Test that setqflist() should not prevent :stopinsert from working
|
|
|
|
|
func Test_setqflist_stopinsert()
|
|
|
|
|
new
|
|
|
|
|
call setqflist([], 'f')
|
|
|
|
|
copen
|
|
|
|
|
cclose
|
|
|
|
|
func StopInsert()
|
|
|
|
|
stopinsert
|
|
|
|
|
call setqflist([{'text': 'foo'}])
|
|
|
|
|
return ''
|
|
|
|
|
endfunc
|
|
|
|
|
|
|
|
|
|
call setline(1, 'abc')
|
|
|
|
|
call cursor(1, 1)
|
|
|
|
|
call feedkeys("i\<C-R>=StopInsert()\<CR>$", 'tnix')
|
|
|
|
|
call assert_equal('foo', getqflist()[0].text)
|
|
|
|
|
call assert_equal([0, 1, 3, 0, v:maxcol], getcurpos())
|
|
|
|
|
call assert_equal(['abc'], getline(1, '$'))
|
|
|
|
|
|
|
|
|
|
delfunc StopInsert
|
|
|
|
|
call setqflist([], 'f')
|
|
|
|
|
bwipe!
|
|
|
|
|
endfunc
|
2022-12-02 12:40:31 -07:00
|
|
|
|
|
2019-10-26 17:06:29 -07:00
|
|
|
|
" vim: shiftwidth=2 sts=2 expandtab
|