atom-community/atom-ide-definitions

`getSuggestionForWord` method in ClickProvider seems to make every word hyperclick-able

Closed this issue ยท 2 comments

I reported this as a side note in atom-community/atom-ide-vue#13, but the relevant code appears to be in this repository.

When I install atom-ide-definitions, atom-ide-vue, and hyperclick, together, every word in my .vue files becomes underlined and hyperclick-able. Here's a screenshot, where the scoped attribute is underlined (the cursor isn't captured by the screenshot, but it over the word), even though it will not have a definition anywhere in a typical Vue codebase.

Screen Shot 2020-01-06 at 11 05 38 AM

Looking at https://github.com/atom-ide-community/atom-ide-definitions/blob/master/lib/clickProvider.js#L11, the implementation of ClickProvider::getSuggestionForWord seems to return an object for every word that is sent to it, when cmd-hovering (for Mac) over code. Hyperclick will treat every symbol as clickable if getSuggestionForWord always returns a truthy object result, hence the behavior I'm seeing.

My assumption is that the click callback is provided (in the Vue example) but atom-ide-vue via options.clickHandler, but that the return value of the getSuggestionForWord function is not controllable by the Vue package. To me, it seems that the language-level atom-ide plugins need to be able to determine whether or not a token has a definition and only return an truthy result if it does.

Belar commented

Hi, as said in the other issue, it's a good point, only items with definition should be highlighted and clickable.

You are right about getSuggestionForWord, it shouldn't return universal handler. We can first check if definition is available (on cmd + hover), base return on that.

๐ŸŽ‰ This issue has been resolved in version 0.3.3 ๐ŸŽ‰

The release is available on:

Your semantic-release bot ๐Ÿ“ฆ๐Ÿš€