Skip to content

Commit 7559dce

Browse files
committed
patch 8.1.1087: tag stack is incorrect after CTRL-T and then :tag
Problem: tag stack is incorrect after CTRL-T and then :tag Solution: Handle DT_TAG differently. (test by Andy Massimino, closes #3944, closes #4177)
1 parent abab0b0 commit 7559dce

3 files changed

Lines changed: 81 additions & 3 deletions

File tree

src/tag.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -504,13 +504,16 @@ do_tag(
504504
tagmatchname = vim_strsave(name);
505505
}
506506

507-
if (type == DT_TAG || type == DT_SELECT || type == DT_JUMP
507+
if (type == DT_SELECT || type == DT_JUMP
508508
#if defined(FEAT_QUICKFIX)
509509
|| type == DT_LTAG
510510
#endif
511511
)
512512
cur_match = MAXCOL - 1;
513-
max_num_matches = cur_match + 1;
513+
if (type == DT_TAG)
514+
max_num_matches = MAXCOL;
515+
else
516+
max_num_matches = cur_match + 1;
514517

515518
/* when the argument starts with '/', use it as a regexp */
516519
if (!no_regexp && *name == '/')
@@ -583,7 +586,7 @@ do_tag(
583586
}
584587
else
585588
#endif
586-
if (type == DT_TAG)
589+
if (type == DT_TAG && *tag != NUL)
587590
/*
588591
* If a count is supplied to the ":tag <name>" command, then
589592
* jump to count'th matching tag.

src/testdir/test_tagjump.vim

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -366,4 +366,77 @@ func Test_getsettagstack()
366366
set tags&
367367
endfunc
368368

369+
func Test_tag_with_count()
370+
call writefile([
371+
\ 'test Xtest.h /^void test();$/;" p typeref:typename:void signature:()',
372+
\ ], 'Xtags')
373+
call writefile([
374+
\ 'main Xtest.c /^int main()$/;" f typeref:typename:int signature:()',
375+
\ 'test Xtest.c /^void test()$/;" f typeref:typename:void signature:()',
376+
\ ], 'Ytags')
377+
cal writefile([
378+
\ 'int main()',
379+
\ 'void test()',
380+
\ ], 'Xtest.c')
381+
cal writefile([
382+
\ 'void test();',
383+
\ ], 'Xtest.h')
384+
set tags=Xtags,Ytags
385+
386+
new Xtest.c
387+
let tl = taglist('test', 'Xtest.c')
388+
call assert_equal(tl[0].filename, 'Xtest.c')
389+
call assert_equal(tl[1].filename, 'Xtest.h')
390+
391+
tag test
392+
call assert_equal(bufname('%'), 'Xtest.c')
393+
1tag test
394+
call assert_equal(bufname('%'), 'Xtest.c')
395+
2tag test
396+
call assert_equal(bufname('%'), 'Xtest.h')
397+
398+
set tags&
399+
call delete('Xtags')
400+
call delete('Ytags')
401+
bwipe Xtest.h
402+
bwipe Xtest.c
403+
call delete('Xtest.h')
404+
call delete('Xtest.c')
405+
endfunc
406+
407+
func Test_tagnr_recall()
408+
call writefile([
409+
\ 'test Xtest.h /^void test();$/;" p',
410+
\ 'main Xtest.c /^int main()$/;" f',
411+
\ 'test Xtest.c /^void test()$/;" f',
412+
\ ], 'Xtags')
413+
cal writefile([
414+
\ 'int main()',
415+
\ 'void test()',
416+
\ ], 'Xtest.c')
417+
cal writefile([
418+
\ 'void test();',
419+
\ ], 'Xtest.h')
420+
set tags=Xtags
421+
422+
new Xtest.c
423+
let tl = taglist('test', 'Xtest.c')
424+
call assert_equal(tl[0].filename, 'Xtest.c')
425+
call assert_equal(tl[1].filename, 'Xtest.h')
426+
427+
2tag test
428+
call assert_equal(bufname('%'), 'Xtest.h')
429+
pop
430+
call assert_equal(bufname('%'), 'Xtest.c')
431+
tag
432+
call assert_equal(bufname('%'), 'Xtest.h')
433+
434+
set tag&
435+
call delete('Xtags')
436+
bwipe Xtest.h
437+
bwipe Xtest.c
438+
call delete('Xtest.h')
439+
call delete('Xtest.c')
440+
endfunc
441+
369442
" vim: shiftwidth=2 sts=2 expandtab

src/version.c

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

776776
static int included_patches[] =
777777
{ /* Add new patch number below this line */
778+
/**/
779+
1087,
778780
/**/
779781
1086,
780782
/**/

0 commit comments

Comments
 (0)