Skip to content

Switch to asynchronous search

Gaël Bonithon requested to merge Tamaranch/mousepad:asynchronous-search into master

Depends on !46 (merged).

The main purpose of this MR is to use asynchronous search, so as not to block the UI when searching in big files and/or with regex search enabled. This is almost required when the search mode is "find as you type", which is the case for Mousepad.

This is in itself a rather profound change that requires a lot of rethinking, but I also took the opportunity to improve and harmonize a few small things regarding the search bar and the replace dialog.

I tried to divide the changes into separate commits as much as possible, but the one directly related to the switch to asynchronous search is obviously bigger and harder to read than the others.

From the user's point of view, in addition to the gain in fluidity thanks to the asynchronous search, the main changes are:

  • the display of the number of matches in the search bar, instead of the "Highlight All" button;
  • this button is moved in the menubar ("Search" menu), where it appears as common to the search bar and the replace dialog without overloading either of them;
  • the display of a spinner when the search is in progress, instead of an outdated or empty occurrences count, both in the search bar and the replace dialog;
  • a better behavior when the documents change (buffers or tabs);
  • a better consistency between the search bar and the replace dialog when used together, within the limits of what is possible.

Codewise, I made increased use of signals to connect the different widgets involved in the search, from the search bar and replace dialog to the documents, through the window and back.

One last thing: I had to trick a bit to avoid prohibitive computation times in some situations, because of (what I consider to be) a bug in GtkSourceView (reproducible e.g. with Gedit in its current stable version): see https://gitlab.gnome.org/GNOME/gtksourceview/-/issues/164

All this is duly commented in the code.

Edited by Gaël Bonithon

Merge request reports