phpcomplete.vim icon indicating copy to clipboard operation
phpcomplete.vim copied to clipboard

Jump to definition doesn't ignore comments in search

Open dkjii-gg opened this issue 6 years ago • 2 comments

see https://github.com/dkjii-gg/phpcomplete-test-2, try going to \t\test(), it brings to \f\test because it falls back to vim default tag search

The reason it does that is that when it looks for the match in the file (to get the line), it doesn't verify that it's not part of a comment

Here's a patch that fixes this (kinda), but it does not handle a lot of valid use-cases (and doesn't even exclude multiline comments)

patch.txt

seems like the jumptodef has a lot of edge cases, universal ctags supports the +n field, which adds the line at which the tag appears, maybe using this would fix all these issues and make the code smaller?

dkjii-gg avatar Jan 21 '19 18:01 dkjii-gg

I'll have to see what we could do, but in theory if you have a cursor position, you can ask vim what sort of syntax highlight symbol it has associated to that position. This is what I've used before for comment detection and I've a simplified syntax file as part of the plugin for this.

I'm not against adding support for new ctag features, but the part in the patch is just reading buffers, need to take a closer look at this.

Thank you once again for the awesomely detailed report!

complex857 avatar Jan 22 '19 08:01 complex857

Personally I would use the tag.cmd to search for the pattern in the temporary buffer, or just use tag.line if it's available

When I'm free I'll see what i can do and maybe submit a patch. BTW, the patch in the first post doesn't work, because it ignore abstract/final classes

Thanks you for the great plugin :P

dkjii-gg avatar Jan 24 '19 15:01 dkjii-gg