Fix O after searching caused empty inputbox.
authorDaniel Carl <danielcarl@gmx.de>
Wed, 14 Jun 2017 21:21:28 +0000 (23:21 +0200)
committerDaniel Carl <danielcarl@gmx.de>
Wed, 14 Jun 2017 21:21:28 +0000 (23:21 +0200)
In case a searching is active vimb is still in normal mode. So
'O'-keypress should write ':open URL' to the inputbox and switch vimb
into command mode. But during the switching of the modes, the already
written ':open ..' string was immediately overwritten by empty string.
So the user was left with cursor in empty inputbox.

Now the input is only cleared on stopping searching when a links was
fired during searching which is done in code during
WEBKIT_LOAD_COMMITTED event processing.

src/command.c
src/main.c

index 28e9a12..c9168e5 100644 (file)
 #include "history.h"
 #include "main.h"
 
+/**
+ * Start/perform/stop searching in webview.
+ *
+ * @commit: If TRUE, the search query is registered into register "/
+ *          In case searching is stopped the commit of value TRUE
+ *          is used to clear the inputbox if search is active. This is needed
+ *          in case a link is fired by <CR> on highlighted link.
+ */
 gboolean command_search(Client *c, const Arg *arg, bool commit)
 {
     WebKitFindController *fc;
@@ -46,8 +54,10 @@ gboolean command_search(Client *c, const Arg *arg, bool commit)
     if (arg->i == 0) {
         webkit_find_controller_search_finish(fc);
 
-        /* Clear the input only if the search is active. */
-        if (c->state.search.active) {
+        /* Clear the input only if the search is active and commit flag is
+         * set. This allows us to stop searching with and without cleaning
+         * inputbox */
+        if (commit && c->state.search.active) {
             vb_echo(c, MSG_NORMAL, FALSE, "");
         }
 
index 90de537..c3fb8de 100644 (file)
@@ -1240,8 +1240,9 @@ static void on_webview_load_changed(WebKitWebView *webview,
             /* clear possible set marks */
             marks_clear(c);
 
-            /* Unset possible last search. */
-            command_search(c, &(Arg){0, NULL}, FALSE);
+            /* Unset possible last search. Use commit==TRUE to clear inputbox
+             * in case a link was fired from highlighted link. */
+            command_search(c, &(Arg){0, NULL}, TRUE);
 
             break;