summaryrefslogtreecommitdiff
path: root/src/command.c
diff options
context:
space:
mode:
authorDaniel Carl <danielcarl@gmx.de>2018-05-28 00:18:34 +0200
committerDaniel Carl <danielcarl@gmx.de>2018-05-28 00:22:41 +0200
commit6eec70212b0ae31911636f4f99a71fc6c9241d59 (patch)
tree4de07c2cc16431b238b149f458c5bd1e8b512eb9 /src/command.c
parent4e8c5b284394b04573be56cdd85eda10b7107194 (diff)
Fix wrong search hit count shown on prev/next.
If a search was done the shown number of search hits was right. But on case of stepping through the list, the match count was updated by 1. Now use the right signal "counted-matches" to get the real number of search hits independent from stepping through the list.
Diffstat (limited to 'src/command.c')
-rw-r--r--src/command.c35
1 files changed, 10 insertions, 25 deletions
diff --git a/src/command.c b/src/command.c
index e851995..118881f 100644
--- a/src/command.c
+++ b/src/command.c
@@ -32,9 +32,6 @@
#include "history.h"
#include "main.h"
-static void on_found_text(WebKitFindController *fc, guint count,
- Client *c);
-
/**
* Start/perform/stop searching in webview.
*
@@ -45,19 +42,15 @@ static void on_found_text(WebKitFindController *fc, guint count,
*/
gboolean command_search(Client *c, const Arg *arg, bool commit)
{
- WebKitFindController *fc;
const char *query;
guint count;
int direction;
- fc = webkit_web_view_get_find_controller(c->webview);
-
g_assert(c);
g_assert(arg);
- g_assert(fc);
if (arg->i == 0) {
- webkit_find_controller_search_finish(fc);
+ webkit_find_controller_search_finish(c->finder);
/* Clear the input only if the search is active and commit flag is
* set. This allows us to stop searching with and without cleaning
@@ -103,8 +96,8 @@ gboolean command_search(Client *c, const Arg *arg, bool commit)
* on the page. Without this workaround the first selected match
* depends on the most recent selection or caret position (even when
* caret browsing is disabled). */
- if(commit) {
- webkit_find_controller_search(fc, "", WEBKIT_FIND_OPTIONS_NONE, G_MAXUINT);
+ if (commit) {
+ webkit_find_controller_search(c->finder, "", WEBKIT_FIND_OPTIONS_NONE, G_MAXUINT);
}
if (!c->state.search.last_query) {
@@ -114,8 +107,11 @@ gboolean command_search(Client *c, const Arg *arg, bool commit)
c->state.search.last_query = g_strdup(query);
}
- g_signal_connect(fc, "found-text", G_CALLBACK(on_found_text), c);
- webkit_find_controller_search(fc, query,
+ webkit_find_controller_count_matches(c->finder, query,
+ WEBKIT_FIND_OPTIONS_CASE_INSENSITIVE |
+ WEBKIT_FIND_OPTIONS_WRAP_AROUND,
+ G_MAXUINT);
+ webkit_find_controller_search(c->finder, query,
WEBKIT_FIND_OPTIONS_CASE_INSENSITIVE |
WEBKIT_FIND_OPTIONS_WRAP_AROUND |
(direction > 0 ? WEBKIT_FIND_OPTIONS_NONE : WEBKIT_FIND_OPTIONS_BACKWARDS),
@@ -133,11 +129,11 @@ gboolean command_search(Client *c, const Arg *arg, bool commit)
if (c->state.search.active) {
if (arg->i * c->state.search.direction > 0) {
while (count--) {
- webkit_find_controller_search_next(fc);
+ webkit_find_controller_search_next(c->finder);
}
} else {
while (count--) {
- webkit_find_controller_search_previous(fc);
+ webkit_find_controller_search_previous(c->finder);
}
}
}
@@ -264,14 +260,3 @@ gboolean command_queue(Client *c, const Arg *arg)
return res;
}
#endif
-
-static void on_found_text(WebKitFindController *fc, guint count,
- Client *c)
-{
- /* Avoid multiple useless status updates in case incsearch is enabled and
- * we get the same count several times. */
- if (c->state.search.matches != count) {
- c->state.search.matches = count;
- vb_statusbar_update(c);
- }
-}