From f159971172b8eebd014a34a41207d3ef5021e288 Mon Sep 17 00:00:00 2001 From: edyfox Date: Wed, 20 Feb 2008 13:07:41 +0000 Subject: [PATCH] Merged from the latest developing branch. git-svn-id: https://vim.svn.sourceforge.net/svnroot/vim/trunk@906 2a77ed30-b011-0410-a7ad-c7884a0aa172 --- src/search.c | 39 ++++++++++++++++++++++++++++----------- src/version.c | 2 ++ 2 files changed, 30 insertions(+), 11 deletions(-) diff --git a/src/search.c b/src/search.c index 1ad1df31..9bdd0379 100644 --- a/src/search.c +++ b/src/search.c @@ -624,7 +624,7 @@ searchit(win, buf, pos, dir, pat, count, options, pat_use, stop_lnum, tm) #ifdef FEAT_EVAL submatch = first_submatch(®match); #endif - /* Line me be past end of buffer for "\n\zs". */ + /* "lnum" may be past end of buffer for "\n\zs". */ if (lnum + matchpos.lnum > buf->b_ml.ml_line_count) ptr = (char_u *)""; else @@ -833,21 +833,38 @@ searchit(win, buf, pos, dir, pat, count, options, pat_use, stop_lnum, tm) continue; } - if (options & SEARCH_END && !(options & SEARCH_NOOF)) + /* With the SEARCH_END option move to the last character + * of the match. Don't do it for an empty match, end + * should be same as start then. */ + if (options & SEARCH_END && !(options & SEARCH_NOOF) + && !(matchpos.lnum == endpos.lnum + && matchpos.col == endpos.col)) { + /* For a match in the first column, set the position + * on the NUL in the previous line. */ pos->lnum = lnum + endpos.lnum; - pos->col = endpos.col - 1; -#ifdef FEAT_MBYTE - if (has_mbyte) + pos->col = endpos.col; + if (endpos.col == 0) { - /* 'e' offset may put us just below the last line */ - if (pos->lnum > buf->b_ml.ml_line_count) - ptr = (char_u *)""; - else - ptr = ml_get_buf(buf, pos->lnum, FALSE); - pos->col -= (*mb_head_off)(ptr, ptr + pos->col); + if (pos->lnum > 1) /* just in case */ + { + --pos->lnum; + pos->col = (colnr_T)STRLEN(ml_get_buf(buf, + pos->lnum, FALSE)); + } } + else + { + --pos->col; +#ifdef FEAT_MBYTE + if (has_mbyte + && pos->lnum <= buf->b_ml.ml_line_count) + { + ptr = ml_get_buf(buf, pos->lnum, FALSE); + pos->col -= (*mb_head_off)(ptr, ptr + pos->col); + } #endif + } } else { diff --git a/src/version.c b/src/version.c index 96a8dd15..21701b79 100644 --- a/src/version.c +++ b/src/version.c @@ -667,6 +667,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 258, +/**/ 257, /**/ 256, -- 2.11.4.GIT