CoffeeTags icon indicating copy to clipboard operation
CoffeeTags copied to clipboard

Adds a lot of tags that it shouldn't add

Open alexlafroscia opened this issue 10 years ago • 5 comments

I've noticed that CoffeeTags has been adding a lot of things as tags where it shouldn't. For example, it's reading any line that starts with document, such as

document.getElementById('arrow')

and marking it as a do block.

Something similar is happening with classes. Every time that I use a method name that has a capital letter in it, CoffeeTags tries to make a new class out of it. So this line

object.classList.add 'class-name'

Will make List.add as a class.

alexlafroscia avatar Aug 29 '14 01:08 alexlafroscia

hi @alexlafroscia - is this a recent thing, or was it always like that?

I don't remember this happening when I was writing CoffeeScript code (and working on CoffeeTags). Granted - it was a while ago

lukaszkorecki avatar Aug 29 '14 10:08 lukaszkorecki

I'm not sure how long it's been happening for... I'm new to Vim and CTags in general. I'm using the TagBar plugin, which recommends using CoffeeTags for CoffeeScript files. Since CoffeeScript is my main language, I wanted to get this set up and working but find I don't even use it because there are so many things in the TagBar that don't even make sense. If there's anything I can send that might help you, let me know. I'd be happy to send you the file that I'm seeing the issue in,

alexlafroscia avatar Aug 29 '14 15:08 alexlafroscia

To me, it just seems like CoffeeTags's regex (which I'm assuming is what it uses under the hood) isn't checking for whitespace after do or before a class declaration, so that it is assuming any line that starts with do (even if it's for document) is a do block, etc.

alexlafroscia avatar Aug 29 '14 15:08 alexlafroscia

Looks like you are partly right about the parser do check not looking for whitespace after. That is wound up in the same regex that does if, unless, switch, and loop checks as well. However, it does look like we are checking for whitespace on class definitions. When I get some time I'll look into adding some tests that duplicate the bug, then try fixing it. Or you are more then welcome to beat me to the punch with a pull request.

mtscout6 avatar Aug 29 '14 16:08 mtscout6

Alright, cool. If I find some free time, I'll play with fixing it myself, but I'm pretty inexperienced with Ruby so I don't know how that would go. Maybe it would be a good exercise though :)

alexlafroscia avatar Aug 30 '14 14:08 alexlafroscia