Skip to content

Commit 1ff2b64

Browse files
committed
patch 7.4.1588
Problem: Old style test for quickfix. Solution: Turn test 96 into a new style test.
1 parent 1c8b4ed commit 1ff2b64

5 files changed

Lines changed: 114 additions & 152 deletions

File tree

src/testdir/Make_all.mak

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,6 @@ SCRIPTS_ALL = \
7979
test93.out \
8080
test94.out \
8181
test95.out \
82-
test96.out \
8382
test98.out \
8483
test99.out \
8584
test101.out \

src/testdir/test96.in

Lines changed: 0 additions & 142 deletions
This file was deleted.

src/testdir/test96.ok

Lines changed: 0 additions & 9 deletions
This file was deleted.

src/testdir/test_quickfix.vim

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -366,3 +366,115 @@ function Test_efm()
366366
call assert_equal("[['W', 1], ['ZZZZ', 0], ['E^@CCCC', 1], ['YYYY', 0]]", l)
367367
let &efm = save_efm
368368
endfunction
369+
370+
" This will test for problems in quickfix:
371+
" A. incorrectly copying location lists which caused the location list to show
372+
" a different name than the file that was actually being displayed.
373+
" B. not reusing the window for which the location list window is opened but
374+
" instead creating new windows.
375+
" C. make sure that the location list window is not reused instead of the
376+
" window it belongs to.
377+
"
378+
" Set up the test environment:
379+
function! ReadTestProtocol(name)
380+
let base = substitute(a:name, '\v^test://(.*)%(\.[^.]+)?', '\1', '')
381+
let word = substitute(base, '\v(.*)\..*', '\1', '')
382+
383+
setl modifiable
384+
setl noreadonly
385+
setl noswapfile
386+
setl bufhidden=delete
387+
%del _
388+
" For problem 2:
389+
" 'buftype' has to be set to reproduce the constant opening of new windows
390+
setl buftype=nofile
391+
392+
call setline(1, word)
393+
394+
setl nomodified
395+
setl nomodifiable
396+
setl readonly
397+
exe 'doautocmd BufRead ' . substitute(a:name, '\v^test://(.*)', '\1', '')
398+
endfunction
399+
400+
function Test_locationlist()
401+
enew
402+
403+
augroup testgroup
404+
au!
405+
autocmd BufReadCmd test://* call ReadTestProtocol(expand("<amatch>"))
406+
augroup END
407+
408+
let words = [ "foo", "bar", "baz", "quux", "shmoo", "spam", "eggs" ]
409+
410+
let qflist = []
411+
for word in words
412+
call add(qflist, {'filename': 'test://' . word . '.txt', 'text': 'file ' . word . '.txt', })
413+
" NOTE: problem 1:
414+
" intentionally not setting 'lnum' so that the quickfix entries are not
415+
" valid
416+
call setloclist(0, qflist, ' ')
417+
endfor
418+
419+
" Test A
420+
lrewind
421+
enew
422+
lopen
423+
lnext
424+
lnext
425+
lnext
426+
lnext
427+
vert split
428+
wincmd L
429+
lopen
430+
wincmd p
431+
lnext
432+
let fileName = expand("%")
433+
wincmd p
434+
let locationListFileName = substitute(getline(line('.')), '\([^|]*\)|.*', '\1', '')
435+
let fileName = substitute(fileName, '\\', '/', 'g')
436+
let locationListFileName = substitute(locationListFileName, '\\', '/', 'g')
437+
call assert_equal("test://bar.txt", fileName)
438+
call assert_equal("test://bar.txt", locationListFileName)
439+
440+
wincmd n | only
441+
442+
" Test B:
443+
lrewind
444+
lopen
445+
2
446+
exe "normal \<CR>"
447+
wincmd p
448+
3
449+
exe "normal \<CR>"
450+
wincmd p
451+
4
452+
exe "normal \<CR>"
453+
call assert_equal(2, winnr('$'))
454+
wincmd n | only
455+
456+
" Test C:
457+
lrewind
458+
lopen
459+
" Let's move the location list window to the top to check whether it (the
460+
" first window found) will be reused when we try to open new windows:
461+
wincmd K
462+
2
463+
exe "normal \<CR>"
464+
wincmd p
465+
3
466+
exe "normal \<CR>"
467+
wincmd p
468+
4
469+
exe "normal \<CR>"
470+
1wincmd w
471+
call assert_equal('quickfix', &buftype)
472+
2wincmd w
473+
let bufferName = expand("%")
474+
let bufferName = substitute(bufferName, '\\', '/', 'g')
475+
call assert_equal('test://quux.txt', bufferName)
476+
477+
wincmd n | only
478+
479+
augroup! testgroup
480+
endfunction

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -748,6 +748,8 @@ static char *(features[]) =
748748

749749
static int included_patches[] =
750750
{ /* Add new patch number below this line */
751+
/**/
752+
1588,
751753
/**/
752754
1587,
753755
/**/

0 commit comments

Comments
 (0)