Skip to content

gui: Cancel previous search when typing new text in search button

Currently when having quite a few disk/CPU activity from another process (like compiling or just running yes), the global file search has a fair bit of latency when typing text, as the previous searchs are having a hard time with IO. So they tend to "pile up" when typing new characters, which means that there's a few seconds where the search results will change several times as search results start arriving.

To prevent this sluggish search, this commit now cancels the previous search request in favor of a fresher one with the newly typed text.

Also fixes a FIXME, where search errors are now reported in the messages pane instead of hidden in the logs.


I noticed this when compiling a kernel, but running yes in a shell exposes the problem too (it consumes 10% CPU here and does IO).

I saw that sometimes there's GLib-GIO[ 2]: CRITICAL: g_task_return_error: assertion '!task->ever_returned' failed that shows in the logs when closing Builder, but I don't think it's my commit that introduced it as the backtrace only mentions jsonrpc:

(gdb) bt
#0  0x00007ffff7abec02 in g_logv () at /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0
#1  0x00007ffff7abee73 in g_log () at /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0
#2  0x00007ffff313933e in error_invocations_from_idle (data=0x55555773e3d0) at ../src/jsonrpc-client.c:243
#3  0x00007ffff7ab72bf in g_main_context_dispatch () at /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0
#4  0x00007ffff7ab7668 in g_main_context_iterate.constprop () at /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0
#5  0x00007ffff7ab7733 in g_main_context_iteration () at /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0
#6  0x00007ffff7ce5808 in g_application_run () at /usr/lib/x86_64-linux-gnu/libgio-2.0.so.0
#7  0x00005555555f4c58 in main (argc=<optimized out>, argv=<optimized out>) at ../../../../../../../../../Projets/gnome/gnome-builder/src/main.c:296

Merge request reports