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

Improve seal filesearch plugin #301

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

yannrouillard
Copy link
Contributor

This PR contains several improvements for the Seal filesearch plugin:

  • fix a race condition that could lead to some search results not being displayed in certain conditions
  • improve responsiveness by reducing the number of time spotlight search is called
  • improve the ranking of results that contains the exact words of the search query
  • better handle the accent so you get results with/without accents

Updated the Seal filesearch plugin to resolve a race
condition which occurred when a new spotlight search
was initiated before the completion of a previous search.
This issue resulted in occasional receipt of obsolete
`didFinish` spotlight events.

To mitigate this, a unique `hs.spotlight` object is now
assigned to each new search, and we disregard any event
or callback that is not related to the current search.

Additionally, the spotlight file search logic has been
isolated into a distinct class for improved clarity.
Contrary to most plugins, the Seal filesearch plugin
doesn't quickly filter results from an existing set
in memory, but it triggers an actual spotlight search
each time.

That is more resource-intensive and calling it too
frequently for each key typed does hurt the responsiveness
of the Seal chooser (lua being single-threaded).

To avoid that, the plugin now uses it own `queryChangedTimerDuration`
parameter so it can be set to higher value compared to the
defaut Seal one.
The default of 100mn provides a good responsiveness
while still display results with an acceptable delay.
Spotlight results naturally put first the items that
were recently accessed.
However it doesn't put first the item that really
contain the word as it (not as a sub-part of the word)
whereas it is often the ones you want first typically.

We emulate that behaviour by re-ordering the results
to boost the item that contains whole words.
@yannrouillard yannrouillard force-pushed the improve-seal-filesearch-plugin branch from e8a4c03 to c01feb2 Compare June 11, 2023 16:11
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.

None yet

1 participant