summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
authorSebastien Helleu <flashcode@flashtux.org>2010-10-06 11:26:33 +0200
committerSebastien Helleu <flashcode@flashtux.org>2010-10-06 11:26:33 +0200
commit8ba491e427beceecfee1ddbc644b72640e9e2caf (patch)
treed591e51a9c994340a59005f4dbb7d8d73567202e /src/gui
parentc3c767c164927a33fd460d2328628a08aba8b094 (diff)
downloadweechat-8ba491e427beceecfee1ddbc644b72640e9e2caf.zip
Optimize incremental search in buffer: do not search any more when chars are added to a text not found (bug #31167)
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/curses/gui-curses-keyboard.c30
1 files changed, 28 insertions, 2 deletions
diff --git a/src/gui/curses/gui-curses-keyboard.c b/src/gui/curses/gui-curses-keyboard.c
index ca6c44c7c..c307c33ff 100644
--- a/src/gui/curses/gui-curses-keyboard.c
+++ b/src/gui/curses/gui-curses-keyboard.c
@@ -350,10 +350,36 @@ gui_keyboard_flush ()
/* incremental text search in buffer */
if ((gui_current_window->buffer->text_search != GUI_TEXT_SEARCH_DISABLED)
- && ((input_old == NULL) || (gui_current_window->buffer->input_buffer == NULL)
+ && ((input_old == NULL)
+ || (gui_current_window->buffer->input_buffer == NULL)
|| (strcmp (input_old, gui_current_window->buffer->input_buffer) != 0)))
{
- gui_window_search_restart (gui_current_window);
+ /*
+ * if current input is longer than old input, and that
+ * beginning of current input is exactly equal to old input,
+ * then do nothing (search will not find any result and can
+ * take some time on buffer with many lines..)
+ */
+ if (!gui_current_window->buffer->text_search_found
+ && (input_old != NULL)
+ && (input_old[0])
+ && (gui_current_window->buffer->input_buffer != NULL)
+ && (gui_current_window->buffer->input_buffer[0])
+ && (strlen (gui_current_window->buffer->input_buffer) > strlen (input_old))
+ && (strncmp (gui_current_window->buffer->input_buffer, input_old,
+ strlen (input_old)) == 0))
+ {
+ /*
+ * do not search text in buffer, just alert about text not
+ * found
+ */
+ if (CONFIG_BOOLEAN(config_look_search_text_not_found_alert))
+ printf ("\a");
+ }
+ else
+ {
+ gui_window_search_restart (gui_current_window);
+ }
}
if (input_old)