diff options
author | 2012-05-25 05:16:59 +0000 | |
---|---|---|
committer | 2012-05-25 05:16:59 +0000 | |
commit | 80ba5842ccc57338ebb50e245e3617a10b29b03a (patch) | |
tree | 848e1c83a7c821c5c9396900e06c051d0a1faa65 | |
parent | Prepare mg buffers before startup file is parsed so multiple files can (diff) | |
download | wireguard-openbsd-80ba5842ccc57338ebb50e245e3617a10b29b03a.tar.xz wireguard-openbsd-80ba5842ccc57338ebb50e245e3617a10b29b03a.zip |
Allow searching (C-s or C-r) to wrap around the ends of a buffer.
Even if the search string is located at the beginning or end of a
buffer.
-rw-r--r-- | usr.bin/mg/search.c | 42 |
1 files changed, 25 insertions, 17 deletions
diff --git a/usr.bin/mg/search.c b/usr.bin/mg/search.c index 1226cb6e144..c825c517532 100644 --- a/usr.bin/mg/search.c +++ b/usr.bin/mg/search.c @@ -1,4 +1,4 @@ -/* $OpenBSD: search.c,v 1.39 2012/04/12 04:47:59 lum Exp $ */ +/* $OpenBSD: search.c,v 1.40 2012/05/25 05:16:59 lum Exp $ */ /* This file is in the public domain. */ @@ -245,17 +245,21 @@ isearch(int dir) ewprintf("Overwrapped I-search: %s", pat); break; } - is_lpush(); pptr = strlen(pat); - (void)forwchar(FFRAND, 1); - if (is_find(SRCH_FORW) != FALSE) - is_cpush(SRCH_MARK); - else { - (void)backchar(FFRAND, 1); - ttbeep(); - success = FALSE; - ewprintf("Failed I-search: %s", pat); + if (forwchar(FFRAND, 1) == FALSE) { + ttbeep(); + success = FALSE; + ewprintf("Failed I-search: %s", pat); + } else { + if (is_find(SRCH_FORW) != FALSE) + is_cpush(SRCH_MARK); + else { + (void)backchar(FFRAND, 1); + ttbeep(); + success = FALSE; + ewprintf("Failed I-search: %s", pat); + } } is_prompt(dir, pptr < 0, success); break; @@ -280,13 +284,17 @@ isearch(int dir) } is_lpush(); pptr = strlen(pat); - (void)backchar(FFRAND, 1); - if (is_find(SRCH_BACK) != FALSE) - is_cpush(SRCH_MARK); - else { - (void)forwchar(FFRAND, 1); - ttbeep(); - success = FALSE; + if (backchar(FFRAND, 1) == FALSE) { + ttbeep(); + success = FALSE; + } else { + if (is_find(SRCH_BACK) != FALSE) + is_cpush(SRCH_MARK); + else { + (void)forwchar(FFRAND, 1); + ttbeep(); + success = FALSE; + } } is_prompt(dir, pptr < 0, success); break; |