Hi Bram and list,

How to reproduce:
- Run vanilla Vim with utf-8 encoding,
  $ vim -Nu NONE --cmd "set enc=utf-8"
- set utf-8 characters.
  :call setline(1, "・最初から最後まで最強のVimは最高")
- Jump cursor to 最
  f最
- Jump cursor to the next one.
  ;

Expected behavior:
- Jump cursor to the next one. 
・最初から最後まで最強のVimは最高
          ^
Actual behavior:
- Cursor does not move.


Investigation result:
- When typed f最
searchc() [search.c:1628]
1628        *lastc = c;
  `c` has been assigned to `*lastc` with downcast from int to char_u.
  `c` assigned Unicode point.
- 最's Unicode point is U+6700
  http://www.fileformat.info/info/unicode/char/6700/index.htm
  That is, `*lastc` is assigned to 0x00.
- When typed ;
1646        if (*lastc == NUL)
1647            return FAIL;
  Actually, although the code of utf-8 is stored in `lastc_bytes`, processing 
is not performed correctly because it matches the above judgment.


Attached patch fixes this problem.
Please check it.

--
Best regards,
Hirohito Higashi (a.k.a. h_east)

-- 
-- 
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

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.
diff --git a/src/Makefile b/src/Makefile
index 0238836..1af1e17 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -2099,6 +2099,7 @@ test_arglist \
 	test_cdo \
 	test_channel \
 	test_charsearch \
+	test_charsearch_utf8 \
 	test_changedtick \
 	test_cindent \
 	test_cmdline \
diff --git a/src/search.c b/src/search.c
index d23dde2..f4a5c6d 100644
--- a/src/search.c
+++ b/src/search.c
@@ -1643,7 +1643,11 @@ searchc(cmdarg_T *cap, int t_cmd)
     }
     else		/* repeat previous search */
     {
-	if (*lastc == NUL)
+	if (*lastc == NUL
+#ifdef FEAT_MBYTE
+		&& lastc_bytelen == 1
+#endif
+		)
 	    return FAIL;
 	if (dir)	/* repeat in opposite direction */
 	    dir = -lastcdir;
diff --git a/src/testdir/test_alot_utf8.vim b/src/testdir/test_alot_utf8.vim
index 3022da3..13724cb 100644
--- a/src/testdir/test_alot_utf8.vim
+++ b/src/testdir/test_alot_utf8.vim
@@ -6,6 +6,7 @@
 " files, so that they can be run by themselves.
 
 set belloff=all
+source test_charsearch_utf8.vim
 source test_expr_utf8.vim
 source test_matchadd_conceal_utf8.vim
 source test_regexp_utf8.vim
diff --git a/src/testdir/test_charsearch_utf8.vim b/src/testdir/test_charsearch_utf8.vim
new file mode 100644
index 0000000..ade7dd4
--- /dev/null
+++ b/src/testdir/test_charsearch_utf8.vim
@@ -0,0 +1,22 @@
+" Tests for related f{char} and t{char} using utf-8.
+if !has('multi_byte')
+  finish
+endif
+
+" Test for t,f,F,T movement commands
+function! Test_search_cmds()
+  new!
+  call setline(1, "・最初から最後まで最強のVimは最高")
+  1
+  normal! f最
+  call assert_equal([0, 1, 4, 0], getpos('.'))
+  normal! ;
+  call assert_equal([0, 1, 16, 0], getpos('.'))
+  normal! 2;
+  call assert_equal([0, 1, 43, 0], getpos('.'))
+  normal! ,
+  call assert_equal([0, 1, 28, 0], getpos('.'))
+  bw!
+endfunction
+
+" vim: shiftwidth=2 sts=2 expandtab

Raspunde prin e-mail lui