diff options
author | Bram Moolenaar <Bram@vim.org> | 2015-12-28 19:20:36 +0100 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2015-12-28 19:20:36 +0100 |
commit | ad4d8a192abf44b89371af87d70b971cd654b799 (patch) | |
tree | ad7554b6a90c075cd2722259604c812842c22c7c /src/search.c | |
parent | a60824308cd9bc192c5d38fc16cccfcf652b40f6 (diff) | |
download | vim-git-ad4d8a192abf44b89371af87d70b971cd654b799.tar.gz |
patch 7.4.984v7.4.984
Problem: searchpos() always starts searching in the first column, which is
not what some people expect. (Brett Stahlman)
Solution: Add the 'z' flag: start at the specified column.
Diffstat (limited to 'src/search.c')
-rw-r--r-- | src/search.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/src/search.c b/src/search.c index 74398e39e..1145558a6 100644 --- a/src/search.c +++ b/src/search.c @@ -578,6 +578,7 @@ last_pat_prog(regmatch) * if (options & SEARCH_KEEP) keep previous search pattern * if (options & SEARCH_FOLD) match only once in a closed fold * if (options & SEARCH_PEEK) check for typed char, cancel search + * if (options & SEARCH_COL) start at pos->col instead of zero * * Return FAIL (zero) for failure, non-zero for success. * When FEAT_EVAL is defined, returns the index of the first matching @@ -599,6 +600,7 @@ searchit(win, buf, pos, dir, pat, count, options, pat_use, stop_lnum, tm) { int found; linenr_T lnum; /* no init to shut up Apollo cc */ + colnr_T col; regmmatch_T regmatch; char_u *ptr; colnr_T matchcol; @@ -711,12 +713,14 @@ searchit(win, buf, pos, dir, pat, count, options, pat_use, stop_lnum, tm) /* * Look for a match somewhere in line "lnum". */ + col = at_first_line && (options & SEARCH_COL) ? pos->col + : (colnr_T)0; nmatched = vim_regexec_multi(®match, win, buf, - lnum, (colnr_T)0, + lnum, col, #ifdef FEAT_RELTIME - tm + tm #else - NULL + NULL #endif ); /* Abort searching on an error (e.g., out of stack). */ @@ -1098,6 +1102,7 @@ set_vv_searchforward() /* * Return the number of the first subpat that matched. + * Return zero if none of them matched. */ static int first_submatch(rp) |