pucelle / vscode-css-navigation

Allowing Go to definition from HTML to CSS, or Find References from CSS to HTML.
https://marketplace.visualstudio.com/items?itemName=pucelle.vscode-css-navigation
MIT License
64 stars 8 forks source link

Got to reference should exclude current item #86

Closed NoelAbrahams closed 1 year ago

NoelAbrahams commented 1 year ago

Hi, thanks for the extension — looks very good.

Given the following:

.foo {
 width:10px;
}

When I right-click on .foo and select 'Go to References' among the items listed is this instance of .foo as well. The current item should be excluded from the search.

That's how it works for example TypeScript classes.

This is quite a pain point because the tool never goes to the first reference. There are always two clicks needed.

Hope this is clear?

pucelle commented 1 year ago

Thanks for your feedback, will work on it soon.

pucelle commented 1 year ago

Not luck, I found this first reference of itself is not generated by my plugin, I guess it is generated by vscode automatically:

References my plugin found: image

References for final: image

NoelAbrahams commented 1 year ago

Maybe worth filing this as a bug on the VSCode repository? Let me know and I can do that for you.

pucelle commented 1 year ago

Never mind, but I don't think this is a bug. If this behavior troubles you, filling a bug would worth it.

NoelAbrahams commented 1 year ago

Not luck, I found this first reference of itself is not generated by my plugin, I guess it is generated by vscode automatically: Are you not able to exclude that first reference?

The go-to-reference feature works correctly for TypeScript files, so there must be a way to fix this?

pucelle commented 1 year ago

Start an issue on vscode would be OK, only them know details.

NoelAbrahams commented 1 year ago

@pucelle I've opened a discussion here: https://github.com/microsoft/vscode-discussions/discussions/778

Please add any info there that you think is necessary.

pucelle commented 1 year ago

OK

burkeholland commented 1 year ago

Off the top of my head, since you're implementing the findReferences, it seems like it would be possible to check for the current file there and ignore it. https://github.com/pucelle/vscode-css-navigation/blob/d86b5c0b3112012e11659355aa028bbec7b96ae3/server/src/server.ts#L373C2-L375C47

pucelle commented 1 year ago

@burkeholland The first reference result, which reference current file, it not generated by this plugin, I cant see it, so its not possible to filter it out.