From e6f4bc018e6378e3d3c4572fa8c4bedf4f69f708 Mon Sep 17 00:00:00 2001
From: Robert Timm <mail@rtti.de>
Date: Mon, 17 Apr 2017 22:41:15 +0200
Subject: [PATCH] moves incsearch to ex_input_changed (closes #370)

---
 src/ex.c | 16 +++++++---------
 1 file changed, 7 insertions(+), 9 deletions(-)

diff --git a/src/ex.c b/src/ex.c
index 79191b2..20e0eaa 100644
--- a/src/ex.c
+++ b/src/ex.c
@@ -348,15 +348,6 @@ VbResult ex_keypress(Client *c, int key)
         }
     }
 
-    if (c->config.incsearch && key != KEY_CR) {
-        gtk_text_buffer_get_bounds(buffer, &start, &end);
-        text = gtk_text_buffer_get_text(buffer, &start, &end, false);
-        if (text && (*text == '/' || *text == '?')) {
-            command_search(c, &((Arg){0, NULL})); /* stop last search */
-            command_search(c, &((Arg){*text == '/' ? 1 : -1, (char*)text + 1}));
-        }
-    }
-
     /* if the user deleted some content of the inputbox we check if the
      * inputbox is empty - if so we switch back to normal like vim does */
     if (check_empty) {
@@ -398,6 +389,13 @@ void ex_input_changed(Client *c, const char *text)
         case 'g':
             /* TODO create hints */
             break;
+        case '/': /* fall through */
+        case '?':
+            if (c->config.incsearch) {
+                command_search(c, &((Arg){0, NULL})); /* stop last search */
+                command_search(c, &((Arg){*text == '/' ? 1 : -1, (char*)text + 1}));
+            }
+            break;
     }
 }
 
-- 
2.20.1