lkundrak / rpms / vim

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