Throttle/debounce the search input

Use case or problem

Currently, Obsidian search tries to update as fast as possible. While it seems to work fine in restricted mode, it sets up for possible performance issues later and it has no practical purpose other than looking cool.

Even performance aside, flashing search results are just noisy and distracting.

When you start typing, first letter result is too broad. Starting to process it before I’m done typing is useless. And in case a plugin tries to process it as well - it raises the required complexity of the plugin. Otherwise, it freezes the app on a big vault.

Performance issue exists in combination with “Better Search Views” plugin.

I will open an issue with “Better Search Views” plugin as well (Update: opened Delay the search update · Issue #58 · ivan-lednev/better-search-views).
But because the current eager search seems unnecessary and distracting, I think it worth also addressing on the Obsidian side.

Proposed solution

Implement throttling/debouncing of the search input. At least as an option to toggle.

  • On input change - don’t fire the search immediately but schedule it with small delay;
  • If I keep typing during active delay - keep extending it;
  • When the delay expired without input change - fire the search.

There might be already implemented solution in form of a framework feature or a library for this purpose. Typical for reactive UI.

Current workaround (optional)

Type the search string somewhere else and paste in the search field. Very annoying.

1 Like