+1

Add feature to seach by content in Files-panel

Anton 1 year ago updated 1 year ago 2

Add feature to seach by content in Files-panel.
Now it's only possible in Graph-panel.

Image 803

+1

Please be more precise what exactly you want to be searched for? Should all files of the selected commit/between selected both commits/local files (if the working tree node is selected) be searched? Or just the visible filtered files?

Please describe your exact usecase.

In general, desired behavior for me and many other users could be:

1. apply these button-filters first:

Image 804

2. only after that, search by a content of the files that remain after previous step. In this case it doesn't matter if working tree is selected in Graph-panel, or a certain commit in Graph-panel is selected or two commits in Graph-panel are selected for comparison.

In all three cases the search will be performed within the files remained on previous step (as now it is shown in Files-panel).

3. After searching by a content completed, only files with matches should be presented in Files-panel.

4. [perhaps this step should be put in a separate feature request] After clicking each remaining file in Files-panel, the found matches should be highlighted by yellow color in source code in "Changes-panel". The idea of highlighting is presented here:

https://smartgit.userecho.com/communities/1/topics/1621-highlight-matches-in-text-with-yellow-color-when-filtering-by-content

5. The matches in text should be highlighted also in "File Compare"-window (i.e. right click the file in File-panel -> "Show changes" menu).

Additional notes about behavior for each kind of files:

For deleted files: search should be performed on a version of a file before deletion obviously (of course, if the file is not filtered out from Files-panel somehow on previous step).

For renamed files: for performance reasons, search can be performed on any of two files, but matches in text should be shown in both of them (renamed files are identical by a content so there is no need to search by its content twice).

For added files: obviously search in added file should be done.

For changed files: search should be done in both files. If match found in one of them the file should remain in a list of files in Files-panel.

For untracked files (if working tree is selected in Graph-panel):

search should be performed by a content of untracked file (of course, if the file is not filtered out from Files-panel somehow on first step).

Ideally [it also maybe be put in a separate feature request], search by a content should be applied together with search by a filename. For example, user could search for a content "hello world" only in files with names: "*Test.cs".

It could be done with a keyword like this:

@content:"hello world" @filename:*Test.cs

This method will improve the search function and give an opportunity to improve it in the future.

Feel free to ask any additional information to clarify this request in future.

> In all three cases the search will be performed within the files remained on previous step (as now it is shown in Files-panel).
In some cases, e.g. 2 selected commits in the Graph, one entry in the Files table could mean multiple files (file states). In which one to search?

Could you also please describe your usecase - why you need this feature?

> why you need this feature?

For fast file search, small changes or copy-paste some part of code in source code files, edited recently.
I remember what I changed recently but don't actually remember which commit or file contains it.

When the commit contains a lot of files edited, I need to filter out files with unneeded changes and find only those containing a keyword (table name, view, stored procedure). I don't want to look into each file in each commit to find a match.
If the file is what I looked for I can open it in editor without starting IDE and modify it, or copy-paste some query to give to a collegue.
But I understad what you mean. Maybe I will try to find any alternative for that.