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

Group search results by root folders #29964

Merged
merged 24 commits into from
Jul 22, 2017
Merged

Group search results by root folders #29964

merged 24 commits into from
Jul 22, 2017

Conversation

keegancsmith
Copy link
Contributor

@keegancsmith keegancsmith commented Jun 30, 2017

This is a work in progress PR to add support for grouping of search results. I am submitting it now since I believe the rest of the work is mostly minor and I'll only getting back to this PR on Monday. So hopefully will get some early feedback.

image

image

TODOs:

  • Add replace actions. (For follow-up PR)
  • Make it works with extraFileResources
  • Always display some FileMatches. Currently will not auto-expand repos if many results
  • Render FileMatch names for relative to folder.
  • Render single folder searches without extra level.
  • Create CSS rule .foldermatch, rather than reusing .filematch.
  • Update textual descriptions of results to take into account folders.
  • Bug in Tree renderer for auto-expanded children

cc @roblourens

@mention-bot
Copy link

@keegancsmith, thanks for your PR! By analyzing the history of the files in this pull request, we identified @sandy081 and @bpasero to be potential reviewers.

@msftclas
Copy link

@keegancsmith,
Thanks for having already signed the Contribution License Agreement. Your agreement was validated by Microsoft. We will now review your pull request.
Thanks,
Microsoft Pull Request Bot

@roblourens
Copy link
Member

roblourens commented Jun 30, 2017

Thanks for the PR, but in the future, I would strongly recommend starting a discussion with us in an issue over a new feature before doing a lot of work to implement it. I plan to look into the search UI for multiroot in depth in July, and while this is one possibility, there are other UI options I want to investigate. I think one could make a good argument for not adding a new level of nodes to the results UI, but I will be experimenting more later.

@roblourens roblourens added workbench-multiroot Multi-root (multiple folders) issues search Search widget and operation issues labels Jun 30, 2017
@keegancsmith
Copy link
Contributor Author

@roblourens apologies for not opening a discussion PR first. I've been working on multi-repo search at Sourcegraph and we found having a flat list of results frustrating. So this PR is really just the next logical step from the current UI, mainly to experiment with to see if it feels good. I understand it may not be the best UX for displaying the search results. Don't worry about it being wasted work, we want to launch a more polished multi-repo search at Sourcegraph soon so it will be used for that. I also want to try out this version to see if it feels any good. If vscode goes a different direction, I'll probably move Sourcegraph towards what vscode does.

Is the next step forward to rather close the PR and open the discussion up on an issue? Is there anything salvageable from this PR that I could maybe cherry-pick/patch into another PR?

@roblourens
Copy link
Member

roblourens commented Jun 30, 2017

No worries, I just opened #29977 for discussion and I'll leave this open. It may be useful if we go this route. I'm about to go out of town for almost a week and will be thinking about it after that. I didn't realize Sourcegraph was working on this too, and I look forward to checking it out!

@nicksnyder
Copy link
Contributor

I didn't realize Sourcegraph was working on this too, and I look forward to checking it out!

@roblourens Would you guys be interested in knowing what we are working on on an ongoing basis? If so, we could figure something out (post our monthly plan on our public issue tracker, share a google doc, send you periodic email, etc.). cc @sqs

@roblourens
Copy link
Member

I would be interested in following along. Posting a monthly plan on github has worked well for us.

@keegancsmith
Copy link
Contributor Author

FYI I have resolved most of the TODOs listed in the PR description. However, they require a little bit of work to be upstreamed here. So if you would like to move forward with this PR I'll cherry-pick/clean them up and push them.

@roblourens
Copy link
Member

Hey @keegancsmith, this is the direction I want to go with the multiroot search UI (should have figured that out earlier but I had to investigate and convince myself). I'd love to take the PR if you are interested in porting the rest of the changes forward. Let me know how I can help.

@keegancsmith
Copy link
Contributor Author

@roblourens great. I'll update the PR this week. What I have should work well, except I neglected the non "read-only" use case. So will also implement the replace action.

If you have any early UX feedback, this is what it looks like on Sourcegraph right now

image

@roblourens
Copy link
Member

Thanks! I think that looks great. The "search groups" feature is interesting!

@keegancsmith
Copy link
Contributor Author

@roblourens I've pushed some changes.

  • I haven't tested what happens when extraFileResources[] is non-empty. How do I get entries into that in the UI?
  • The informational text {0} result in {1} file is now {0} file in {1} folder. I can include file count if you have a suggestions for how to word it.
  • Including folderQueries as part of the search test cases was done naively. I can refactor the tests to be more readable as part of this PR if ya like.
  • Find Replace All works. I have only tested via clicking on the find replace button.
  • The action buttons are hidden for folders. Maybe could be done as a follow-up PR?
  • If we only have one folder in the workspace, we still render the extra level. I can change in this PR, but could also be a follow-up PR if ya like.

Some updated screenshots

image

image

image

@roblourens
Copy link
Member

Looks awesome so far, thanks! Few comments:

I haven't tested what happens when extraFileResources[] is non-empty. How do I get entries into that in the UI?

Those are files that are open in the window but don't belong to a workspace. You can use the "open" dialog to open something outside of a root folder. I'm not sure how they should be organized in the UI. I suppose they should get their own node. "Other files" or something.

The informational text {0} result in {1} file is now {0} file in {1} folder.

Hm, I think the result count is still more relevant. I think a typical workspace will only have a few root folders. I think the result count should still be included, and the folder count maybe could be omitted, or maybe like {0} results in {1} files in {2} folders.

Including folderQueries as part of the search test cases was done naively. I can refactor the tests to be more readable as part of this PR if ya like.

That's ok. Are the folderQueries added because the result needs to belong to a workspace, otherwise it will be lost? I think this is related to the extraFileResources issue then?

The action buttons are hidden for folders. Maybe could be done as a follow-up PR?

I think the folders should have action buttons, but I don't need everything in one PR.

If we only have one folder in the workspace, we still render the extra level. I can change in this PR, but could also be a follow-up PR if ya like.

I think in general, the experience for a non-workspace window should be the same as it currently is. This would also mean showing a single level with extraFileResources mixed in to the workspace results. I think I'd like to have this before I send this change out.

@keegancsmith
Copy link
Contributor Author

That all sounds great to me.

I think in general, the experience for a non-workspace window should be the same as it currently is. This would also mean showing a single level with extraFileResources mixed in to the workspace results. I think I'd like to have this before I send this change out.

Should I render as a single level when there is only one folder query, or should I use the contextService to determine that. So for the latter a workspace with one folder will get the new rendering.

@roblourens
Copy link
Member

I think that we should try to match what shows up in the File Explorer. There, a workspace with one folder shows the one root folder node at the top, so let's match that.

@keegancsmith
Copy link
Contributor Author

@roblourens ok I've done everything except the action bar for FolderMatches. PTAL

image

@keegancsmith keegancsmith changed the title WIP Group search results by root folders Group search results by root folders Jul 20, 2017
We want to be able to use the fields from IQueryOptions. Specifically, we want
to be able to use folderResources, so we can render results within each folder
in its own tree node.
We introduce a new class `FolderMatch`. It is responsible for all the life-cycle
management of `FileMatch` that `SearchResult` used to own. As such most of the
implementation is code factored out of `SearchResult`, with most of what
`SearchResult` did now just delegating to the respective `FolderMatch`.
`FolderMatch` is also rendered, so implements some functions for rendering, so
is not a pure "subset" of the `SearchResult` functionality.
We expect a lot more matches in general for folder matches. So just always
expand.
We never want to mutate the query of an existing FolderMatch, so rather make it
part of the constructor.
This reverts commit 2bcd0d99c6997ebbbc91c41d4e0dff8ae8b3503c.
I believe the file count information is more interesting than number of line
matches. And to avoid a very long line when adding folder matches, I removed the
line matches.
This lead to us not autoexpanding FolderMatches, since on creation they would be
empty and only later be populated.
Mimics `.filematch`, but does not hide the count badge on hover or highlight.
This may change when we support actions on the folder.
We want to add a fallback for other resources. Directly using the TrieMap allows
us to do that. Using Workspace is also a bit heavier than what we needed.
@keegancsmith
Copy link
Contributor Author

Aah I have test failures. I ran ./scripts/test.sh -g search, but that excludes tests which just mentioned Search. I'll fix.

@keegancsmith
Copy link
Contributor Author

Rebased against latest master and pushed fix

@roblourens
Copy link
Member

Thanks a ton, this looks great. I've tested on Mac and Windows, and the code looks good. I'm going to wait until after today's insiders build to merge, because if any issues come up, I don't want it to be stuck in insiders for the weekend.

@felixfbecker
Copy link
Contributor

Awesome, looking forward to this!

@roblourens roblourens merged commit 9da0fa1 into microsoft:master Jul 22, 2017
@keegancsmith keegancsmith deleted the foldermatch branch July 25, 2017 10:24
@ssalka
Copy link

ssalka commented Mar 3, 2020

Is this feature no longer supported? My team uses a monorepo, so would be great if my search results could be grouped by, for example, server and frontend (two of our top-level folders in the repo)

However, wasn't able to find any settings available for configuring this 😕


Edit: found #20224. Surprised this still isn't done nearly 3 years later

@github-actions github-actions bot locked and limited conversation to collaborators Mar 27, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
search Search widget and operation issues workbench-multiroot Multi-root (multiple folders) issues
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants