summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorChad Loder <cloder@cvs.openbsd.org>2005-05-25 23:04:40 +0000
committerChad Loder <cloder@cvs.openbsd.org>2005-05-25 23:04:40 +0000
commit5dc861443631307176aa23f5c3372ef48d11dc4d (patch)
tree3b963b1ce07295ebe6707c03fc65cc3990a11a7f /usr.bin
parent5b1225a6cc3f0975994316e1fe3570cb648bda7d (diff)
Incremental search will now wrap to beginning (or end if backwards) if
you hit the search key again after a failure. OK jason
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/mg/search.c26
1 files changed, 23 insertions, 3 deletions
diff --git a/usr.bin/mg/search.c b/usr.bin/mg/search.c
index b3a363921ca..21e5cd21db8 100644
--- a/usr.bin/mg/search.c
+++ b/usr.bin/mg/search.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: search.c,v 1.13 2005/05/23 20:39:44 jason Exp $ */
+/* $OpenBSD: search.c,v 1.14 2005/05/25 23:04:39 cloder Exp $ */
/*
* Search commands.
@@ -220,8 +220,18 @@ isearch(int dir)
is_cpush(SRCH_FORW);
success = TRUE;
}
- if (success == FALSE && dir == SRCH_FORW)
+ if (success == FALSE && dir == SRCH_FORW) {
+ /* wrap the search to beginning */
+ clp = lforw(curbp->b_linep);
+ curwp->w_dotp = clp;
+ curwp->w_doto = 0;
+ if (is_find(dir) != FALSE) {
+ is_cpush(SRCH_MARK);
+ success = TRUE;
+ }
break;
+ }
+
is_lpush();
pptr = strlen(pat);
(void)forwchar(FFRAND, 1);
@@ -241,8 +251,18 @@ isearch(int dir)
is_cpush(SRCH_BACK);
success = TRUE;
}
- if (success == FALSE && dir == SRCH_BACK)
+ if (success == FALSE && dir == SRCH_BACK) {
+ /* wrap the search to end */
+ clp = lback(curbp->b_linep);
+ curwp->w_dotp = clp;
+ curwp->w_doto =
+ llength(curwp->w_dotp);
+ if (is_find(dir) != FALSE) {
+ is_cpush(SRCH_MARK);
+ success = TRUE;
+ }
break;
+ }
is_lpush();
pptr = strlen(pat);
(void)backchar(FFRAND, 1);