Fix case where searching backwards from a multibyte character on the
same line results in a wrong cursor offset. Given the buffer:

    0123❤

With the cursor on the 3-byte UTF-8 character ❤ (U+2764), calling the
command

    :call search('.', 'b')

places the cursor on "1" instead of "3". This is due to erroneously
counting the length of the character as an extra offset, which is not
needed when searching backwards.
---
 src/search.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/search.c b/src/search.c
index d7bfc43..8e058eb 100644
--- a/src/search.c
+++ b/src/search.c
@@ -572,7 +572,8 @@ searchit(win, buf, pos, dir, pat, count, options, pat_use, 
stop_lnum, tm)
        extra_col = 0;
 #ifdef FEAT_MBYTE
     /* Watch out for the "col" being MAXCOL - 2, used in a closed fold. */
-    else if (has_mbyte && pos->lnum >= 1 && pos->lnum <= 
buf->b_ml.ml_line_count
+    else if (dir != BACKWARD && has_mbyte
+                   && pos->lnum >= 1 && pos->lnum <= buf->b_ml.ml_line_count
                                                     && pos->col < MAXCOL - 2)
     {
        ptr = ml_get_buf(buf, pos->lnum, FALSE) + pos->col;
-- 
1.8.0.2

-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

Raspunde prin e-mail lui