jasonnutter / vscode-search-node-modules

Simple plugin for VS Code that allows you to quickly navigate the file inside your project's node_modules directory.
https://marketplace.visualstudio.com/items?itemName=jasonnutter.search-node-modules
MIT License
60 stars 17 forks source link

Suggestion: Add ability to search in parent folders #13

Closed OriMarron closed 5 years ago

OriMarron commented 5 years ago

background

In #11 I attempted to solve the use-case of a user opening a monorepo with several projects, by allowing to search in any of them.

However, some users prefer not to open the entire monorepo, but rather only a single project from it - and I want to address this use-case as well.

Since some node modules may be hoisted to the root level by lerna/yarn, they may be located outside the scope of the VSCode workspace, and the user can't find them.

My suggestion is to have the search results also include node_modules from parent directories.

image

details

consider the following structure of a monorepo:

root
├── lerna.json
├── node_modules
│   └── jquery
└── packages
    └── project-a
        ├── node_modules 
        │   └── jquery-ui
        └── src

The folder opened in VSCode is /packages/project-a. jquery is unfortunately out of scope for the search.

With this new feature, instead of only searching under the workspace directory, the extension will also search above it. i.e. Recursively traversing the directory tree upwards looking for /node_modules.

Note:

@jasonnutter

jasonnutter commented 5 years ago

Nice improvement, thanks again!

jasonnutter commented 5 years ago

@OriMarron Heads up, this appears to get into an infinite loop on Windows. I'm gonna see if I can figure it out before I go to sleep, otherwise I might revert and get the other changes published.

jasonnutter commented 5 years ago

Figured out the infinite loop, but there still a couple of UX things I would like to address (for example, I would like the behavior of the options added to the bottom of the quick pick for going up a level and back to root to be consistent/predictable regardless of where you are, which isn't the case with these new changes), so I will take a look at those tomorrow.

OriMarron commented 5 years ago

Hi @jasonnutter I would really like to see this published, and I'm willing to help with whatever is needed :)

deadcoder0904 commented 5 years ago

Hey, @OriMarron will this solve https://github.com/jasonnutter/vscode-search-node-modules/issues/23#issuecomment-519087317? Is it already published?

OriMarron commented 5 years ago

@deadcoder0904 I believe it will solve the original question, but not your use-case which is slightly different. In any case, a new version of the extension was not published yet as far as I know.