Skip to content

Improve search behavior in the file browser - #7679

Merged
sakertooth merged 38 commits into
LMMS:masterfrom
sakertooth:revamp-search
Oct 24, 2025
Merged

Improve search behavior in the file browser#7679
sakertooth merged 38 commits into
LMMS:masterfrom
sakertooth:revamp-search

Conversation

@sakertooth

@sakertooth sakertooth commented Feb 2, 2025

Copy link
Copy Markdown
Contributor

This PR changes the search functionality within the file browser, with the intent of improving the code and user experience.

Changes:

  • Search results are no longer shown in a hierarchy, but instead as a flat list, with only the found directories being hierarchical. This aligns better with most file managers and greatly simplifies the search code (no need to convolute things by attempting to build a hierarchy).
  • Searching now considers finding all supported files. This means that searching is no longer limited to finding only specific files from the extensions we support. For example, the project tab is no longer limited to only showing for e.g. project files when searching through it. This also applies to searching within any other specific tab as well.
  • Searching now follows symlinks.
  • Searching now supports finding hidden files if the "Hidden content" checkbox is enabled. Likewise, it will ignore hidden files if the checkbox is disabled.
  • Stop checking for paths to exclude from listing/searching (explained in 1a9643f)
  • Uses tokenization instead of matching the entire search filter

@sakertooth

Copy link
Copy Markdown
Contributor Author

For some reason while searching, there is a segfault when closing the program. Doesn't seem to be a concern, but unsure why this happens.

Reducing the search space for performance is no longer a problem now, so there's no harm in allowing these directories to be considered (and we can avoid potential problems with how files are organized on users machines). Making sure to always check agaisnt the blacklist was also a bit error-prone since its possible to forget to check against it (like with how searching was implemented here, but it did not seem to matter at that point).
@sakertooth
sakertooth marked this pull request as draft February 4, 2025 22:02
@sakertooth
sakertooth marked this pull request as ready for review February 4, 2025 22:56
Most notable differences are that we cancel the search automatically in the destructor when closing the application, and we use a mutex to prevent ordering conflicts when beginning and ending searches.
@AW1534

AW1534 commented Feb 5, 2025

Copy link
Copy Markdown
Member

Searching no longer considers extensions.

Does this mean I can no longer, for example, type "mid" and see all my midis? this is something I do often and I think this behaviour should be preserved.

@sakertooth

sakertooth commented Feb 5, 2025

Copy link
Copy Markdown
Contributor Author

Searching no longer considers extensions.

Does this mean I can no longer, for example, type "mid" and see all my midis? this is something I do often and I think this behaviour should be preserved.

No, it's just that the search is no longer limited by files with certain extensions. Instead, the search now considers all files regardless of its extension. If you type "mid", it will treat it as a token and find any file that has it in its name. ".mid" will probably find all midis for you.

I did this because if a file was named "foo.medi" but was a perfectly working midi file, then the search wouldn't find it if it considered extensions regardless if the search filter was for e.g. ".medi".

Since we always cancel the search if one is already running before starting up a new one, theres no need for mutual exclsuion since the cancellation logic should provide that.
We shouldn't update the search indicator directly in the onSearch function because those updates may get out of order with the updates that are queued by the auxiliary thread, potentially resulting in inconsistent state.
@sakertooth sakertooth changed the title Revamp searching in the file browser Improve search behavior in the file browser Feb 6, 2025
@bratpeki bratpeki self-assigned this Feb 18, 2025
@bratpeki

Copy link
Copy Markdown
Member

Is this ready for testing?

@sakertooth

Copy link
Copy Markdown
Contributor Author

Is this ready for testing?

Feel free.

@bratpeki

bratpeki commented Mar 1, 2025

Copy link
Copy Markdown
Member

Hell yeah! Merge ASAP. 🚀

@AW1534

AW1534 commented Mar 2, 2025

Copy link
Copy Markdown
Member

Searching looks good but im not a big fan of the file path being in the context menu as these can get long
image
It also seems slightly redundant after #7700

Edit:maybe change it to only show the parent dir instead of the whole canonical file path?

@sakertooth

Copy link
Copy Markdown
Contributor Author

We could use ellipsis, but yeah I guess I can remove it.

@sakertooth

Copy link
Copy Markdown
Contributor Author

Edit:maybe change it to only show the parent dir instead of the whole canonical file path?

Something like parent_directory/file_name.wav?

@sakertooth

Copy link
Copy Markdown
Contributor Author

Okay, new double quote feature added and bugs fixed, it should be fine now. Any testing will be appreciated 👍

@AW1534

AW1534 commented Jun 1, 2025

Copy link
Copy Markdown
Member

image
This works beautifully, no issues found!

@AW1534 AW1534 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@bratpeki

bratpeki commented Jun 1, 2025

Copy link
Copy Markdown
Member

Gonna retest!

@AW1534

AW1534 commented Aug 18, 2025

Copy link
Copy Markdown
Member

Anything blocking this from being merged?

@sakertooth

Copy link
Copy Markdown
Contributor Author

Anything blocking this from being merged?

Other than the merge conflicts, I think @bratpeki mentioned a bug with this PR in the Discord that I haven't got around to fixing yet.

@sakertooth

Copy link
Copy Markdown
Contributor Author

Hello, quick update: I don't think I have any remaining things to do for this PR. If anyone wants to revisit this/do some final testing, I appreciate it. In any case, I think this is ready for merge.

@tresf tresf left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested, couldn't find anything obviously wrong with it.

This does get a bit taxing for things like Volumes and My Home especially if you have mounted network volumes or additional drives, but if that becomes an issue, we can file an enhancement later.

Thanks for the hard work on this @sakertooth!

@messmerd messmerd left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me code-wise

Comment thread include/FileBrowser.h
Comment thread include/FileBrowser.h
Comment thread include/FileSearch.h Outdated
@sakertooth

Copy link
Copy Markdown
Contributor Author

Will get back to this soon @messmerd. To any maintainers, just don't merge this right now.

@sakertooth

Copy link
Copy Markdown
Contributor Author

This does get a bit taxing for things like Volumes and My Home especially if you have mounted network volumes or additional drives, but if that becomes an issue, we can file an enhancement later.

I agree. It is tasking performance wise, I experienced this as well at certain times. I think ideally we wouldn't be searching throughout the entire home directory but instead use more specific paths. We could probably also remove Home and Root because we have the "Favorites" section now thanks to work done by @AW1534 (but this might cause backlash so not sure if we want to pursue it in the future).

@sakertooth
sakertooth merged commit 0c69da7 into LMMS:master Oct 24, 2025
11 checks passed
@sakertooth
sakertooth deleted the revamp-search branch October 24, 2025 14:10
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.

6 participants