Karsten Hopp 95c411
To: vim_dev@googlegroups.com
Karsten Hopp 95c411
Subject: Patch 7.4.926
Karsten Hopp 95c411
Fcc: outbox
Karsten Hopp 95c411
From: Bram Moolenaar <Bram@moolenaar.net>
Karsten Hopp 95c411
Mime-Version: 1.0
Karsten Hopp 95c411
Content-Type: text/plain; charset=UTF-8
Karsten Hopp 95c411
Content-Transfer-Encoding: 8bit
Karsten Hopp 95c411
------------
Karsten Hopp 95c411
Karsten Hopp 95c411
Patch 7.4.926
Karsten Hopp 95c411
Problem:    Completing the longest match doesn't work properly with multi-byte
Karsten Hopp 95c411
            characters.
Karsten Hopp 95c411
Solution:   When using multi-byte characters use another way to find the
Karsten Hopp 95c411
            longest match. (Hirohito Higashi)
Karsten Hopp 95c411
Files:      src/ex_getln.c, src/testdir/test_utf8.in, src/testdir/test_utf8.ok
Karsten Hopp 95c411
Karsten Hopp 95c411
Karsten Hopp 95c411
*** ../vim-7.4.925/src/ex_getln.c	2015-08-11 19:13:55.138175689 +0200
Karsten Hopp 95c411
--- src/ex_getln.c	2015-11-19 18:55:39.355292662 +0100
Karsten Hopp 95c411
***************
Karsten Hopp 95c411
*** 3691,3710 ****
Karsten Hopp 95c411
      /* Find longest common part */
Karsten Hopp 95c411
      if (mode == WILD_LONGEST && xp->xp_numfiles > 0)
Karsten Hopp 95c411
      {
Karsten Hopp 95c411
! 	for (len = 0; xp->xp_files[0][len]; ++len)
Karsten Hopp 95c411
  	{
Karsten Hopp 95c411
! 	    for (i = 0; i < xp->xp_numfiles; ++i)
Karsten Hopp 95c411
  	    {
Karsten Hopp 95c411
  		if (p_fic && (xp->xp_context == EXPAND_DIRECTORIES
Karsten Hopp 95c411
  			|| xp->xp_context == EXPAND_FILES
Karsten Hopp 95c411
  			|| xp->xp_context == EXPAND_SHELLCMD
Karsten Hopp 95c411
  			|| xp->xp_context == EXPAND_BUFFERS))
Karsten Hopp 95c411
  		{
Karsten Hopp 95c411
! 		    if (TOLOWER_LOC(xp->xp_files[i][len]) !=
Karsten Hopp 95c411
! 					    TOLOWER_LOC(xp->xp_files[0][len]))
Karsten Hopp 95c411
  			break;
Karsten Hopp 95c411
  		}
Karsten Hopp 95c411
! 		else if (xp->xp_files[i][len] != xp->xp_files[0][len])
Karsten Hopp 95c411
  		    break;
Karsten Hopp 95c411
  	    }
Karsten Hopp 95c411
  	    if (i < xp->xp_numfiles)
Karsten Hopp 95c411
--- 3691,3727 ----
Karsten Hopp 95c411
      /* Find longest common part */
Karsten Hopp 95c411
      if (mode == WILD_LONGEST && xp->xp_numfiles > 0)
Karsten Hopp 95c411
      {
Karsten Hopp 95c411
! 	int mb_len = 1;
Karsten Hopp 95c411
! 	int c0, ci;
Karsten Hopp 95c411
! 
Karsten Hopp 95c411
! 	for (len = 0; xp->xp_files[0][len]; len += mb_len)
Karsten Hopp 95c411
  	{
Karsten Hopp 95c411
! #ifdef FEAT_MBYTE
Karsten Hopp 95c411
! 	    if (has_mbyte)
Karsten Hopp 95c411
  	    {
Karsten Hopp 95c411
+ 		mb_len = (*mb_ptr2len)(&xp->xp_files[0][len]);
Karsten Hopp 95c411
+ 		c0 =(* mb_ptr2char)(&xp->xp_files[0][len]);
Karsten Hopp 95c411
+ 	    }
Karsten Hopp 95c411
+ 	    else
Karsten Hopp 95c411
+ #endif
Karsten Hopp 95c411
+ 		c0 = xp->xp_files[i][len];
Karsten Hopp 95c411
+ 	    for (i = 1; i < xp->xp_numfiles; ++i)
Karsten Hopp 95c411
+ 	    {
Karsten Hopp 95c411
+ #ifdef FEAT_MBYTE
Karsten Hopp 95c411
+ 		if (has_mbyte)
Karsten Hopp 95c411
+ 		    ci =(* mb_ptr2char)(&xp->xp_files[i][len]);
Karsten Hopp 95c411
+ 		else
Karsten Hopp 95c411
+ #endif
Karsten Hopp 95c411
+ 		    ci = xp->xp_files[i][len];
Karsten Hopp 95c411
  		if (p_fic && (xp->xp_context == EXPAND_DIRECTORIES
Karsten Hopp 95c411
  			|| xp->xp_context == EXPAND_FILES
Karsten Hopp 95c411
  			|| xp->xp_context == EXPAND_SHELLCMD
Karsten Hopp 95c411
  			|| xp->xp_context == EXPAND_BUFFERS))
Karsten Hopp 95c411
  		{
Karsten Hopp 95c411
! 		    if (MB_TOLOWER(c0) != MB_TOLOWER(ci))
Karsten Hopp 95c411
  			break;
Karsten Hopp 95c411
  		}
Karsten Hopp 95c411
! 		else if (c0 != ci)
Karsten Hopp 95c411
  		    break;
Karsten Hopp 95c411
  	    }
Karsten Hopp 95c411
  	    if (i < xp->xp_numfiles)
Karsten Hopp 95c411
***************
Karsten Hopp 95c411
*** 3714,3719 ****
Karsten Hopp 95c411
--- 3731,3737 ----
Karsten Hopp 95c411
  		break;
Karsten Hopp 95c411
  	    }
Karsten Hopp 95c411
  	}
Karsten Hopp 95c411
+ 
Karsten Hopp 95c411
  	ss = alloc((unsigned)len + 1);
Karsten Hopp 95c411
  	if (ss)
Karsten Hopp 95c411
  	    vim_strncpy(ss, xp->xp_files[0], (size_t)len);
Karsten Hopp 95c411
*** ../vim-7.4.925/src/testdir/test_utf8.in	2015-06-25 16:09:20.706461152 +0200
Karsten Hopp 95c411
--- src/testdir/test_utf8.in	2015-11-19 18:42:47.987598529 +0100
Karsten Hopp 95c411
***************
Karsten Hopp 95c411
*** 17,22 ****
Karsten Hopp 95c411
--- 17,41 ----
Karsten Hopp 95c411
  :	$put=strchars(str, 0)
Karsten Hopp 95c411
  :	$put=strchars(str, 1)
Karsten Hopp 95c411
  :endfor
Karsten Hopp 95c411
+ :" Test for customlist completion
Karsten Hopp 95c411
+ :function! CustomComplete1(lead, line, pos)
Karsten Hopp 95c411
+ :	return ['あ', 'い']
Karsten Hopp 95c411
+ :endfunction
Karsten Hopp 95c411
+ :command -nargs=1 -complete=customlist,CustomComplete1 Test1 :
Karsten Hopp 95c411
+ :call feedkeys(":Test1 \<C-L>'\<C-B>$put='\<CR>", 't')
Karsten Hopp 95c411
+ :
Karsten Hopp 95c411
+ :function! CustomComplete2(lead, line, pos)
Karsten Hopp 95c411
+ :	return ['あたし', 'あたま', 'あたりめ']
Karsten Hopp 95c411
+ :endfunction
Karsten Hopp 95c411
+ :command -nargs=1 -complete=customlist,CustomComplete2 Test2 :
Karsten Hopp 95c411
+ :call feedkeys(":Test2 \<C-L>'\<C-B>$put='\<CR>", 't')
Karsten Hopp 95c411
+ :
Karsten Hopp 95c411
+ :function! CustomComplete3(lead, line, pos)
Karsten Hopp 95c411
+ :	return ['Nこ', 'Nん', 'Nぶ']
Karsten Hopp 95c411
+ :endfunction
Karsten Hopp 95c411
+ :command -nargs=1 -complete=customlist,CustomComplete3 Test3 :
Karsten Hopp 95c411
+ :call feedkeys(":Test3 \<C-L>'\<C-B>$put='\<CR>", 't')
Karsten Hopp 95c411
+ :
Karsten Hopp 95c411
  :call garbagecollect(1)
Karsten Hopp 95c411
  :/^start:/,$wq! test.out
Karsten Hopp 95c411
  ENDTEST
Karsten Hopp 95c411
*** ../vim-7.4.925/src/testdir/test_utf8.ok	2015-06-25 16:09:20.706461152 +0200
Karsten Hopp 95c411
--- src/testdir/test_utf8.ok	2015-11-19 18:42:47.987598529 +0100
Karsten Hopp 95c411
***************
Karsten Hopp 95c411
*** 17,19 ****
Karsten Hopp 95c411
--- 17,22 ----
Karsten Hopp 95c411
  1
Karsten Hopp 95c411
  1
Karsten Hopp 95c411
  1
Karsten Hopp 95c411
+ Test1 
Karsten Hopp 95c411
+ Test2 あた
Karsten Hopp 95c411
+ Test3 N
Karsten Hopp 95c411
*** ../vim-7.4.925/src/version.c	2015-11-19 17:56:09.434210164 +0100
Karsten Hopp 95c411
--- src/version.c	2015-11-19 18:45:37.129781729 +0100
Karsten Hopp 95c411
***************
Karsten Hopp 95c411
*** 743,744 ****
Karsten Hopp 95c411
--- 743,746 ----
Karsten Hopp 95c411
  {   /* Add new patch number below this line */
Karsten Hopp 95c411
+ /**/
Karsten Hopp 95c411
+     926,
Karsten Hopp 95c411
  /**/
Karsten Hopp 95c411
Karsten Hopp 95c411
-- 
Karsten Hopp 95c411
Amnesia is one of my favorite words, but I forgot what it means.
Karsten Hopp 95c411
Karsten Hopp 95c411
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
Karsten Hopp 95c411
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
Karsten Hopp 95c411
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
Karsten Hopp 95c411
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///