Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mixed relative and absolute paths #70

Closed
blueyed opened this issue Apr 6, 2016 · 12 comments
Closed

Mixed relative and absolute paths #70

blueyed opened this issue Apr 6, 2016 · 12 comments

Comments

@blueyed
Copy link
Contributor

blueyed commented Apr 6, 2016

I've noticed that a full update (GutentagsUpdate!) would use relative filenames, but a partial update for the current file (GutentagsUpdate) absolute ones.
This causes Vim (Neovim) then to display the tag selection with :tj, because the path differs.
Can you confirm this?

I am using universal-ctags, and reported the issue there in a pull request, which fixes this when using --tag-relative=yes: universal-ctags/ctags#868.
Since the code in this area appears to date back to the early days of ctags, I assume that this affects gutentags in general?!

A fix might be to make UPDATED_SOURCE local to the tags file?!

@blueyed
Copy link
Contributor Author

blueyed commented Apr 6, 2016

@gruberjuliannama
?

You seem to have pasted parts of my comment and code from the PR (#71)?
Am I missing something?

@ZyX-I
Copy link

ZyX-I commented Jul 4, 2016

At commit cbc163f I still have the same problem. When trying to resolve it I used g:gutentags_cache_dir = $XDG_DATA_HOME . '/gutentags/tags' and as I guessed now all paths are absolute, but this does not fix core issue: duplicate entries:

:tag ostream_in_mpack_init
  # при тип  метка                  файл
  1 F C f    ostream_in_mpack_init  /home/zyx/a.a/Proj/c/neovim/src/nvim/api/private/obj_stream.c
               ObjStreamIn ostream_in_mpack_init(ObjStreamReader read)
  2 F C f    ostream_in_mpack_init  /home/zyx/a.a/Proj/c/neovim/src/nvim/api/private/obj_stream.c
               ObjStreamIn ostream_in_mpack_init(ObjStreamReader read)

@ludovicchabant
Copy link
Owner

The reason you have duplicate symbols seems to be different, as the 2 paths look the same?

@ZyX-I
Copy link

ZyX-I commented Jul 5, 2016

I do not think it is different because the way to reproduce is the same:

  1. Remove tags file.
  2. Do :GutentagsUpdate!.
  3. Do :write. If I am not mistaking, this is the same thing as doing GutentagsUpdate.

Also without g:gutentags_cache_dir I have absolute and relative path like @blueyed had. I guess this means that tags file contains two identical entries, but Vim is not removing duplicates.

@blueyed
Copy link
Contributor Author

blueyed commented Jul 5, 2016

FWIW: my issue was fixed with #71 (not merged, because it depends on Python).

@blueyed
Copy link
Contributor Author

blueyed commented Jul 5, 2016

@ZyX-I
Make sure to look at the tags file for the paths - Vim might adjust them, i.e. although one is relative, you see them both as absolute.

@ZyX-I
Copy link

ZyX-I commented Jul 5, 2016

This is something else: file contains exactly one entry, but project root contains tags file as well which I remember myself removing before checking behaviour with g:gutentags_cache_dir. So g:gutentags_cache_dir is indeed fixing things for me (unless I have somehow hit an issue when tags file is generated in different locations).

@ludovicchabant
Copy link
Owner

ludovicchabant commented Jul 20, 2016

So let's try to not get confused by various different bugs. The OP was about mixed relative and absolute paths.

To be clear, this is what I figured out when I was writing Gutentags:

  • ctags generates absolute paths if an absolute project path is given, and relative paths if a relative project path (such as .) is given.
  • The --tag-relative option only works when you pass a relative project path. If you pass an absolute project path, it ignores it and generates absolute paths in the tags file.
  • Both the original ctags and Universal Ctags behave like this.

Gutentags has 2 modes: tags file at the root of the project (1), and tags file in some cache directory somewhere (2).

Unless I'm missing something clever, mode 1 can (and probably should) use relative paths, whereas mode 2 should use absolute paths because the cache directory and project directory are probably totally unrelated. This is why Gutentags passes . and a relative tags filename in mode 1, and absolute paths to both in mode 2 (see this block of code). As a result, Gutentags never uses the --tag-relative option.

I believe I fixed the bug @blueyed originally reported with 09fbdfc (I wasn't properly doing that "relative/absolute" switch depending on mode 1 and 2 for single-file updates). The problem is really that I let Gutentags put the tags files in a cache directory, so I don't personally test much "mode 1" (I have to look into automated Vim testing to make sure I don't break things).

@MaikoID
Copy link

MaikoID commented Aug 9, 2016

Hey guys, I want to congratulate you all for all work done so far but I can't get satisfied with it, there are so many bugs. Is there any stable release with a minimum functionality any where?

Currently I'm having the same issue, if I enable the cache with:

let g:gutentags_cache_dir = $XDG_DATA_HOME . '.tags'

The duplicate continues to occur but without the mix, all tags remains duplicated with full path.

@ludovicchabant
Copy link
Owner

I haven't set up branches or labels, no, but you're right, I should probably do that at some point (whenever we can actually identify a "stable" release, really).

Since you're using $XDG_DATA_HOME I assume you're on some Unix-flavored OS? (I'm asking because I noticed that on Windows, it's easy to get mixed slashes/backslashes, which can confuse Gutentags and you end up with duplicates with different slash orientations).

@MaikoID
Copy link

MaikoID commented Aug 10, 2016

Hi @ludovicchabant thanks for you answer.

I think that I resolved the problem removing the option cscopetag from my nvimrc and keeping the cache option;

@cbrwizard
Copy link

I had this issue when I had tags generated by a command

ctags -R --languages=c# --exclude=.git --exclude=log .

And after that I opened a folder I generated ctags for with Vim with this plugin installed and I saw the duplicated tags with absolute and relative paths. Then I quit vim, removed the tags file and ran a :GutentagsUpdate command. This helped, now Ctrl+] goes to a correct definition without showing the duplicates.

I am new to Vim (learned about ctags just 2h ago) so it's not a surprise that I did something wrong here. Hopefully my solution will help the other newbies [:

MartyLake added a commit to MartyLake/vim-gutentags that referenced this issue Jan 15, 2024
Disables the detection of tags_file_is_local.
Adds an additional way of fixing ludovicchabant#70 , by forcing only absolute paths.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants
@blueyed @ZyX-I @ludovicchabant @cbrwizard @MaikoID and others