summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDaniel Carl <danielcarl@gmx.de>2014-02-24 10:06:47 +0100
committerDaniel Carl <danielcarl@gmx.de>2014-02-24 10:12:12 +0100
commit0a28c145cea84e61717853852a854675b1075953 (patch)
tree5d0cae81007f86f4d5243eab4e5a5fd5bc1d4fa4 /src
parent09c1a9d7ae8a47e5d5944e591e834795f5f37b07 (diff)
Don't skip first search match after committing search query.
If the user typed the search text into inputbox, the search started. After the search query was commited via <CR> the search went forward a match. But like in vim the first found match should keep the first one after the search query is commited.
Diffstat (limited to 'src')
-rw-r--r--src/command.c22
1 files changed, 12 insertions, 10 deletions
diff --git a/src/command.c b/src/command.c
index 0f34713..5133598 100644
--- a/src/command.c
+++ b/src/command.c
@@ -33,16 +33,14 @@ gboolean command_search(const Arg *arg)
{
static short dir; /* last direction 1 forward, -1 backward*/
static char *query = NULL;
-#ifdef FEATURE_SEARCH_HIGHLIGHT
- static gboolean highlight = false;
-#endif
+ static gboolean newsearch = true;
gboolean forward;
if (arg->i == 0) {
#ifdef FEATURE_SEARCH_HIGHLIGHT
webkit_web_view_unmark_text_matches(vb.gui.webview);
- highlight = false;
#endif
+ newsearch = true;
return true;
}
@@ -57,24 +55,28 @@ gboolean command_search(const Arg *arg)
if (query) {
unsigned int count = abs(arg->i);
+ if (newsearch) {
#ifdef FEATURE_SEARCH_HIGHLIGHT
- if (!highlight) {
/* highlight matches if the search is started new or continued
* after switch to normal mode which calls this function with
* COMMAND_SEARCH_OFF */
webkit_web_view_mark_text_matches(vb.gui.webview, query, false, 0);
webkit_web_view_set_highlight_text_matches(vb.gui.webview, true);
+#endif
- /* mark the search as active */
- highlight = true;
+ newsearch = false;
+ /* skip first search because this is done during typing in ex
+ * mode, else the search wil mark the next match as active */
+ if (count) {
+ count -= 1;
+ }
}
-#endif
- do {
+ while (count--) {
if (!webkit_web_view_search_text(vb.gui.webview, query, false, forward, true)) {
break;
}
- } while (--count);
+ };
}
return true;