patch 7.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.
diff --git a/src/search.c b/src/search.c
index 74398e3..1145558 100644
--- a/src/search.c
+++ b/src/search.c
@@ -578,6 +578,7 @@
* 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 @@
{
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 @@
/*
* 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 @@
/*
* Return the number of the first subpat that matched.
+ * Return zero if none of them matched.
*/
static int
first_submatch(rp)