oliver / gedit-file-search

Gedit plugin to search a text in all files in a directory
https://oliver.github.io/gedit-file-search/
43 stars 11 forks source link

Option to collapse all matches in a specific folder #6

Open jpfleury opened 13 years ago

jpfleury commented 13 years ago

After searching, we can realize that all matches in a specific subfolder are not relevant for us. It would be very useful to have an option in the "right click menu" to collapse all these results. Example:

Say results are:

- folder1/file1
- folder1/file2
- folder2/file1
- folder2/file2
- folder3/file1
- folder4/file1
- folder4/file2
- folder4/file3
- folder4/file4
- folder4/file5
- folder4/file6
- folder4/file7
- folder4/file8
- folder4/file9
- folder4/file10
- folder5/file1

A lot of matches are in "folder4". If they are irrelevant for us, we could click right on any result of this subfolder and have the following choices:

Copy
----
Expand All
Collapse All
Collapse all matches in "folder4"

Written in a more generic form, the new option would be Collapse all matches in "%(folder of the clicked match)s".

oliver commented 13 years ago

What if the result list is like this:

- folderA/folder1/file1
- folderA/folder1/file2
- folderA/folder2/file1
- folderA/folder2/file2
- folderB/folder1/file1
- folderB/folder1/file2
- folderB/folder2/file1
- folderB/folder2/file2

What should the context menu for the first entry show: "Collapse folderA" or "Collapse folder1"?

jpfleury commented 13 years ago

I think it would make it very clear if it showed the direct parent, so Collapse "folder1" (or Collapse "folderA/folder1" if relative path is displayed).

oliver commented 13 years ago

Hm... collapsing the direct parent would be good to get consistent and reliable behavior. However, how about a case like this, which is not uncommon:

- file-search/ui.py
- file-search/searcher.py
- file-search/locale/de/LC_MESSAGES/file-search.po
- file-search/locale/fr/LC_MESSAGES/file-search.po
- file-search/locale/ru/LC_MESSAGES/file-search.po
- testbranch/abc
- testbranch/bar
- testbranch/foo

It would be useful to hide all .po files, and to collapse the entire "locale" directory, but that would not be possible if the context menu only offers "Collapse LC_MESSAGES". It might be possible to automatically detect that "locale" is the common ancestor of all three .po files, and offer "Collapse locale" in context menu; but that would be an unpredictable behavior which might be irritating during use.

A completely different way would be to arrange all results in the list in a tree structure, similar to their location in the file system (I think Kdevelop 4 does that); but that might create lots of useless directory entries even for normal uses.

Yet another solution might be to detect which part of the path the user has clicked on when opening the context menu, and offer to collapse that directory part. I guess that would be difficult to implement, and might not be obvious to the user.

Well I'm really not sure yet what to do :-)

jpfleury commented 13 years ago

What about adding all parents in the context menu? Example:

Copy
----
Expand All
Collapse All
----
Collapse "file-search/locale/de/LC_MESSAGES"
Collapse "file-search/locale/de"
Collapse "file-search/locale"
Collapse "file-search"

Or maybe add x parents, for example 3 parents: direct parent, grandparent and great-grand-parent.