Repository navigation
Description
Issue Type: Bug
I've searched related issues:
- Find usages (find all file references / find all folder references) #66162
- Context menu 'Find all references' on files from file explorer. #66150
- Find all references doesn't work on closed files #52127
- "Find all references" does not work with javascript require when files closed #58972
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
- Export something from file A:
// file-a.js
function doSomething() {
console.log('Hello There');
}
export default doSomething;- Import that file in other files:
// file-b.js
import doSomething from './file-a'
doSomething();- Right-click
doSomethinginfile-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% |
Activity
gjsjohnmurray commentedon Jun 12, 2019
Do you have a jsconfig.json file? See this comment on another issue.
gjsjohnmurray commentedon Jun 12, 2019
Also #52127, #58972
alexilyaev commentedon Jun 12, 2019
John Murray (@gjsjohnmurray) Indeed
jsconfig.jsonmade 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 commentedon Jun 12, 2019
See the docs for more details on jsconfigs
alexilyaev commentedon Jun 13, 2019
Matt Bierner (@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.jsonfile 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 commentedon Jun 14, 2019
Agreeing with Alex Ilyaev (@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 commentedon Jun 14, 2019
Matt Bierner (@mjbvz) maybe the extension implementing the ReferenceProvider in this case could at least show a warning message if there's no
jsconfig.jsonand so it won't be able to do a comprehensive job of answering the user's Find All References request.elektronik2k5 commentedon Jul 10, 2019
I also agree with Alex Ilyaev (@alexilyaev) and Jake-Convictional. If the feature functions only as "Find references in open files" without a valid
jsconfig.jsonin 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.