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

Suggestion: Add ability to search in parent folders #13

Merged
merged 2 commits into from
May 18, 2019

Conversation

OriMarron
Copy link
Contributor

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:

  • All found node modules will include their relative path (e.g. ../../node_modules) to indicate their non-trivial location.

  • The parent modules will only be included when searching at the root level of the workspace, meaning that after a specific folder is selected for traversing, these extra modules will not appear.

  • When traversing a specific module from a parent folder, the extra option to navigate back to root/node_modules will appear, but the extra option to step back (..) that is usually shown, will not be shown, since it will only take you further away from the workspace.

  • You can opt out of this feature by turning off the new configuration field searchParentModules

  • This feature can work together with the one suggested in Suggestion: Add initial support for Lerna monorepos #11. They are meant for different use-cases, and will not break each other

@jasonnutter

@jasonnutter jasonnutter self-assigned this May 8, 2019
@jasonnutter
Copy link
Owner

Nice improvement, thanks again!

@jasonnutter jasonnutter merged commit 720debc into jasonnutter:master May 18, 2019
@jasonnutter
Copy link
Owner

@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
Copy link
Owner

jasonnutter commented Jun 3, 2019

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
Copy link
Contributor Author

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

@deadcoder0904
Copy link

Hey, @OriMarron will this solve #23 (comment)? Is it already published?

@OriMarron
Copy link
Contributor Author

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants