Mercurial > vim
diff src/normal.c @ 18358:34d5cd432cac v8.1.2173
patch 8.1.2173: searchit() has too many arguments
Commit: https://github.com/vim/vim/commit/92ea26b925a0835badb0af2d5887238a4198cabb
Author: Bram Moolenaar <Bram@vim.org>
Date: Fri Oct 18 20:53:34 2019 +0200
patch 8.1.2173: searchit() has too many arguments
Problem: Searchit() has too many arguments.
Solution: Move optional arguments to a struct. Add the "wrapped" argument.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Fri, 18 Oct 2019 21:00:04 +0200 |
parents | 9f51d0cef8da |
children | 709c6b0dc78f |
line wrap: on
line diff
--- a/src/normal.c +++ b/src/normal.c @@ -65,7 +65,7 @@ static void nv_end(cmdarg_T *cap); static void nv_dollar(cmdarg_T *cap); static void nv_search(cmdarg_T *cap); static void nv_next(cmdarg_T *cap); -static int normal_search(cmdarg_T *cap, int dir, char_u *pat, int opt); +static int normal_search(cmdarg_T *cap, int dir, char_u *pat, int opt, int *wrapped); static void nv_csearch(cmdarg_T *cap); static void nv_brackets(cmdarg_T *cap); static void nv_percent(cmdarg_T *cap); @@ -2346,7 +2346,7 @@ find_decl( for (;;) { t = searchit(curwin, curbuf, &curwin->w_cursor, NULL, FORWARD, - pat, 1L, searchflags, RE_LAST, (linenr_T)0, NULL, NULL); + pat, 1L, searchflags, RE_LAST, NULL); if (curwin->w_cursor.lnum >= old_pos.lnum) t = FAIL; /* match after start is failure too */ @@ -3730,7 +3730,7 @@ nv_ident(cmdarg_T *cap) init_history(); add_to_history(HIST_SEARCH, buf, TRUE, NUL); - (void)normal_search(cap, cmdchar == '*' ? '/' : '?', buf, 0); + (void)normal_search(cap, cmdchar == '*' ? '/' : '?', buf, 0, NULL); } else { @@ -4257,7 +4257,7 @@ nv_search(cmdarg_T *cap) (void)normal_search(cap, cap->cmdchar, cap->searchbuf, (cap->arg || !EQUAL_POS(save_cursor, curwin->w_cursor)) - ? 0 : SEARCH_MARK); + ? 0 : SEARCH_MARK, NULL); } /* @@ -4267,16 +4267,17 @@ nv_search(cmdarg_T *cap) static void nv_next(cmdarg_T *cap) { - pos_T old = curwin->w_cursor; - int i = normal_search(cap, 0, NULL, SEARCH_MARK | cap->arg); - - if (i == 1 && EQUAL_POS(old, curwin->w_cursor)) + pos_T old = curwin->w_cursor; + int wrapped = FALSE; + int i = normal_search(cap, 0, NULL, SEARCH_MARK | cap->arg, &wrapped); + + if (i == 1 && !wrapped && EQUAL_POS(old, curwin->w_cursor)) { /* Avoid getting stuck on the current cursor position, which can * happen when an offset is given and the cursor is on the last char * in the buffer: Repeat with count + 1. */ cap->count1 += 1; - (void)normal_search(cap, 0, NULL, SEARCH_MARK | cap->arg); + (void)normal_search(cap, 0, NULL, SEARCH_MARK | cap->arg, NULL); cap->count1 -= 1; } } @@ -4291,17 +4292,22 @@ normal_search( cmdarg_T *cap, int dir, char_u *pat, - int opt) /* extra flags for do_search() */ + int opt, // extra flags for do_search() + int *wrapped) { int i; + searchit_arg_T sia; cap->oap->motion_type = MCHAR; cap->oap->inclusive = FALSE; cap->oap->use_reg_one = TRUE; curwin->w_set_curswant = TRUE; + vim_memset(&sia, 0, sizeof(sia)); i = do_search(cap->oap, dir, pat, cap->count1, - opt | SEARCH_OPT | SEARCH_ECHO | SEARCH_MSG, NULL, NULL); + opt | SEARCH_OPT | SEARCH_ECHO | SEARCH_MSG, &sia); + if (wrapped != NULL) + *wrapped = sia.sa_wrapped; if (i == 0) clearop(cap->oap); else