summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog2
-rw-r--r--src/gui/curses/gui-curses-keyboard.c30
2 files changed, 30 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index 8e5c58f78..087c2681e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -10,6 +10,8 @@ Version 0.3.4 (under dev!)
* core: add new options weechat.look.input_share and
weechat.look.input_share_overwrite (task #9228)
* core: add new option weechat.look.prefix_align_min (task #10650)
+* core: optimize incremental search in buffer: do not search any more
+ when chars are added to a text not found (bug #31167)
* core: fix memory leaks when removing item in hashtable and when setting
highlight words in buffer
* core: use similar behaviour for keys bound to local or global history
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)