Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: Find All References in JS only shows references in open files #75341

Closed
alexilyaev opened this issue Jun 12, 2019 · 8 comments
Closed

Bug: Find All References in JS only shows references in open files #75341

alexilyaev opened this issue Jun 12, 2019 · 8 comments
Assignees
Labels
javascript JavaScript support issues *question Issue represents a question, should be posted to StackOverflow (VS Code)

Comments

@alexilyaev
Copy link

alexilyaev commented Jun 12, 2019

Issue Type: Bug

I've searched related issues:

I'm specifically talking about finding references of a symbol in JavaScript (ES modules) that is being exported.
Basically the opposite of Go To Definition (across files).

Reproduction Steps

  1. Export something from file A:
// file-a.js
function doSomething() {
  console.log('Hello There');
}

export default doSomething;
  1. Import that file in other files:
// file-b.js
import doSomething from './file-a'

doSomething();
  1. Right-click doSomething in file-a.js > Find All References

Expected

Should show file-b.js in the results.

Actual

file-b.js in not shown in the results (unless it is already opened in the editor!)

Notes

  • Same behavior if using named exports instead of default export

Updates based on comments

Adding jsconfig.json does solve this issue, based on this comment, BUT...
I really think it should work out of the box.

Migrating from WebStorm, this is an expected behavior, considering the fact that I've opened a folder in VS Code (meaning that's the project I want to work on).
I manage many different projects, do I now need to add jsconfig.json in each and every one of them?
This adds unnecessary friction.

Suggestion

I wish VS Code would just take a guess that I want all of the files in my project to be included for the Find All References feature.
Probably best to ignore node_modules and alike by default as well.

System Info

VS Code version: Code - Insiders 1.36.0-insider (f291714, 2019-06-12T05:18:48.847Z)
OS version: Darwin x64 18.6.0

System Info
Item Value
CPUs Intel(R) Core(TM) i7-4770HQ CPU @ 2.20GHz (8 x 2200)
GPU Status 2d_canvas: enabled
flash_3d: enabled
flash_stage3d: enabled
flash_stage3d_baseline: enabled
gpu_compositing: enabled
multiple_raster_threads: enabled_on
native_gpu_memory_buffers: enabled
oop_rasterization: disabled_off
protected_video_decode: unavailable_off
rasterization: enabled
skia_deferred_display_list: disabled_off
skia_renderer: disabled_off
surface_synchronization: enabled_on
video_decode: enabled
viz_display_compositor: disabled_off
webgl: enabled
webgl2: enabled
Load (avg) 2, 2, 2
Memory (System) 16.00GB (0.67GB free)
Process Argv
Screen Reader no
VM 0%
Extensions: none
@vscodebot vscodebot bot added the javascript JavaScript support issues label Jun 12, 2019
@gjsjohnmurray
Copy link
Contributor

Do you have a jsconfig.json file? See this comment on another issue.

@gjsjohnmurray
Copy link
Contributor

Also #52127, #58972

@alexilyaev
Copy link
Author

alexilyaev commented Jun 12, 2019

@gjsjohnmurray Indeed jsconfig.json made it work, I've updated the description under Updates based on comments.

Basically, I think this should work out of the box.
More Configuration === More Friction.
Especially when migrating from WebStorm.

@mjbvz
Copy link
Collaborator

mjbvz commented Jun 12, 2019

See the docs for more details on jsconfigs

@mjbvz mjbvz closed this as completed Jun 12, 2019
@mjbvz mjbvz added the *question Issue represents a question, should be posted to StackOverflow (VS Code) label Jun 12, 2019
@alexilyaev
Copy link
Author

@mjbvz I understand the desire to close issues, especially when there's a working solution.

May I suggest, though, to reconsider this one.

There is a way that VS Code could provide a better experience for developers.
The minimum I'd expect is that VS Code would offer to add a jsconfig.json file when using a feature that heavily relies on that configuration.
Otherwise, "Find All References" by definition won't find all references and will be considered broken (as it has been several times already and will continue in the future).

But ideally, similar to how WebStorm works, VS Code could identify projects of certain natures and make a good guess by default, or at least offer a specific configuration based on the prediction (btw, WebStorm does that for many things like linters, file watchers, transpilers, etc.).

@Jake-Convictional
Copy link

Agreeing with @alexilyaev here, regardless of what the documentation says, this is a user experience bug. I just noticed this behaviour myself because it led to me introducing a bug into our production system, though I was sure that I had checked Find All References to confirm that the function I modified was only used in one place.

If Find All References doesn't mean Find All References, then the name should be changed.

@gjsjohnmurray
Copy link
Contributor

@mjbvz maybe the extension implementing the ReferenceProvider in this case could at least show a warning message if there's no jsconfig.json and so it won't be able to do a comprehensive job of answering the user's Find All References request.

@elektronik2k5
Copy link

elektronik2k5 commented Jul 10, 2019

I also agree with @alexilyaev and @Jake-Convictional. If the feature functions only as "Find references in open files" without a valid jsconfig.json in the project, then it should say so instead of misleading, surprising and disappointing users.

One of the basic principles of UX is "don't surprise the user" and this is a clear and particularly bad violation of that rule.

@vscodebot vscodebot bot locked and limited conversation to collaborators Jul 27, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
javascript JavaScript support issues *question Issue represents a question, should be posted to StackOverflow (VS Code)
Projects
None yet
Development

No branches or pull requests

5 participants