summaryrefslogtreecommitdiff
path: root/src/search.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2006-02-24 23:53:04 +0000
committerBram Moolenaar <Bram@vim.org>2006-02-24 23:53:04 +0000
commit32466aa2e9c45ab355dbaf99a9eedf334bc2e29f (patch)
tree1644d959a04f9f8c6ea5a8fe3c79f037c6915559 /src/search.c
parent2a3f7eeebfa05a33cc1d8fbba66a3dff976e8dd7 (diff)
downloadvim-git-32466aa2e9c45ab355dbaf99a9eedf334bc2e29f.tar.gz
updated for version 7.0206v7.0206
Diffstat (limited to 'src/search.c')
-rw-r--r--src/search.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/src/search.c b/src/search.c
index c0be23ba7..e92985a8c 100644
--- a/src/search.c
+++ b/src/search.c
@@ -602,7 +602,11 @@ searchit(win, buf, pos, dir, pat, count, options, pat_use)
# ifdef FEAT_EVAL
submatch = first_submatch(&regmatch);
# endif
- ptr = ml_get_buf(buf, lnum + matchpos.lnum, FALSE);
+ /* Line me be past end of buffer for "\n\zs". */
+ if (lnum + matchpos.lnum > buf->b_ml.ml_line_count)
+ ptr = (char_u *)"";
+ else
+ ptr = ml_get_buf(buf, lnum + matchpos.lnum, FALSE);
/*
* Forward search in the first line: match should be after
@@ -886,6 +890,15 @@ searchit(win, buf, pos, dir, pat, count, options, pat_use)
return FAIL;
}
+ /* A pattern like "\n\zs" may go past the last line. */
+ if (pos->lnum > buf->b_ml.ml_line_count)
+ {
+ pos->lnum = buf->b_ml.ml_line_count;
+ pos->col = STRLEN(ml_get_buf(buf, pos->lnum, FALSE));
+ if (pos->col > 0)
+ --pos->col;
+ }
+
return submatch + 1;
}