From a5e283370dd8b20d69dcddfd50f2e5b1f8f6be77 Mon Sep 17 00:00:00 2001 From: Daniel Carl Date: Wed, 14 Jun 2017 23:21:28 +0200 Subject: [PATCH] Fix O after searching caused empty inputbox. 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 | 14 ++++++++++++-- src/main.c | 5 +++-- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/src/command.c b/src/command.c index 28e9a12..c9168e5 100644 --- a/src/command.c +++ b/src/command.c @@ -31,6 +31,14 @@ #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 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, ""); } diff --git a/src/main.c b/src/main.c index 90de537..c3fb8de 100644 --- a/src/main.c +++ b/src/main.c @@ -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; -- 2.20.1