Skip to content

Conversation

@p-bakker
Copy link

Implements #445

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You have \s* inside of the parentheses for name[1], which makes comparing the group directly to [ will fail (unintentionally, it appears) when there's whitespace after the opening bracket.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm trying to figure out in which scenario the regex would fail, but can't figure it out. All scenario's I test seem to work:

[name] 
 [name] 
[ name] 
 [ name]    
[name ] 
 [name  ] 
[ name ] 
 [ name  ]  

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This produces false:

/^\s*(\[?\s*)([^\]\s]+)\s*(\]?).*/.exec("[ name]")[1] == "["

So my impression is that your code doesn't actually add the question mark when there is whitespace after the [.

@p-bakker
Copy link
Author

Fixed the anomaly

@marijnh
Copy link
Member

marijnh commented Dec 15, 2014

Thanks. Merged as f127557

@marijnh marijnh closed this Dec 15, 2014
@Sevin777
Copy link
Contributor

Sevin777 commented Mar 7, 2015

This is not working properly when using optional parameter and default value (the parameter is not displayed as optional)

http://usejsdoc.org/tags-param.html
image

Example of Problem

http://ternjs.net/doc/demo.html
image

Proper Behavior

My Tern plugin modifies the contents of tooltips by re-parsing the jsdocs. I just upgraded to the latest Tern version which is why I found this issue as I had to update my re-parsing and matching with terns arg hints data due to the ? now being appended to optional params. I'm NOT suggesting that tern modifies it's response to look like my arg hints, I'm just showing that tern should recognize that the second parameter is optional.
image

marijnh added a commit that referenced this pull request Mar 12, 2015
@marijnh
Copy link
Member

marijnh commented Mar 12, 2015

Attached patch should fix the parsing of [foo=10] style parameter declarations.

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

Successfully merging this pull request may close these issues.

3 participants