Given the source code listed at the end of this message, and a tags file
generated from that source, I will demonstrate that a bug in the operation
of the :tag command has been introduced after Vim 6.3, and persists today.

When navigating the tag stack with the :tag and :pop commands, Vim is
supposed to remember which one of many matching tags I previously
selected, so that as I climb and descend the tag stack, I return to the
same location I originally jumped to.

The helpfile states that the tag match number won't change when using :pop
or :tag. (tagsrch.txt for Vim version 7.1, line 130)

However, I find that when I use the :tag command without arguments to
climb the tag stack, the cursor jumps to the first tag entry in the match
list instead of the one I selected.  The tag stack is updated so that the
current entry points to the first matching tag instead of the one I chose.

The relevant documentation is located at
:help :pop
:help :tag
:help :tags

I have reproduced this bug in several Vim versions ranging from 7.0 to a
fully-patched 7.2, on both Windows XP and Linux.

Steps to reproduce:
1.  Generate a tags file from the source code below.

2.  Open the file with `vim -u NONE main.c`

3.  Position the cursor on the call to func1() in main() on line 32.
    Press 'g Ctrl-]' and choose to jump to the definition of func1() that
    takes an integer argument.  From there, jump to the definition of
    func2() that also takes an integer.  Finally, jump into the definition
    of func3().
    At this point, the output of :tags should look like this:

  # TO tag         FROM line  in file/text
  1  2 func1              32  func1(i);
  2  2 func2               5  func2(i);
  3  1 func3              15  func3(i);
>

4.  :3pop your way back to the bottom of the tag stack.
    At this point, the output of :tags should look like this:

  # TO tag         FROM line  in file/text
> 1  2 func1              32  func1(i);
  2  2 func2               5  func2(i);
  3  1 func3              15  func3(i);

    Notice that the tag number from the match list (the number beneath the
    heading "TO") hasn't changed.

5.  If you are following these steps in Vim version <= 6.3, the :tag command
    will return you to the same definition of func1() that you had
    selected earlier, that is, your cursor will jump to the definition of
    func1(int i).
    If you are following along in a version of Vim > 6.3, the :tag command
    will instead jump the cursor to the first definition of func1() found
    in the tags file, func1(double d).
    In Vim > 6.3, the output of :tags now looks like this:

  # TO tag         FROM line  in file/text
  1  1 func1              32  func1(i);
> 2  2 func2               5  func2(i);
  3  1 func3              15  func3(i);

    As I have stated before, this is incorrect because the :tag command
    should not modify the match number, and should return the cursor to
    the definition of func1(int)

/* main.c */
/* vim:set nofoldenable filetype=c: */

void func1(int i) /* i want to come here FIRST */
{
    func2(i);
}

void func1(double d)
{
    func2(d);
}

void func2(int i)  /* i want to come here SECOND */
{
    func3(i);
}

void func2(double d)
{
    int i;
    func3(i);
}

void func3(int i)
{
    i++;
}

int main(void)
{
    int i;
    func1(i);
}

/* EOF */


-- 
Erik Falor
Registered Linux User #445632 http://counter.li.org

--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_dev" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Raspunde prin e-mail lui