Mercurial > vim
comparison src/ex_getln.c @ 7235:e45271250496 v7.4.926
commit https://github.com/vim/vim/commit/4f8fa1633cdfbd09a41160c8480fe67c198067e9
Author: Bram Moolenaar <Bram@vim.org>
Date: Thu Nov 19 19:00:05 2015 +0100
patch 7.4.926
Problem: Completing the longest match doesn't work properly with multi-byte
characters.
Solution: When using multi-byte characters use another way to find the
longest match. (Hirohito Higashi)
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Thu, 19 Nov 2015 19:15:04 +0100 |
parents | 286fd54c7ae3 |
children | 99476f1aaacd |
comparison
equal
deleted
inserted
replaced
7234:7f588bdd1b03 | 7235:e45271250496 |
---|---|
3689 } | 3689 } |
3690 | 3690 |
3691 /* Find longest common part */ | 3691 /* Find longest common part */ |
3692 if (mode == WILD_LONGEST && xp->xp_numfiles > 0) | 3692 if (mode == WILD_LONGEST && xp->xp_numfiles > 0) |
3693 { | 3693 { |
3694 for (len = 0; xp->xp_files[0][len]; ++len) | 3694 int mb_len = 1; |
3695 { | 3695 int c0, ci; |
3696 for (i = 0; i < xp->xp_numfiles; ++i) | 3696 |
3697 { | 3697 for (len = 0; xp->xp_files[0][len]; len += mb_len) |
3698 { | |
3699 #ifdef FEAT_MBYTE | |
3700 if (has_mbyte) | |
3701 { | |
3702 mb_len = (*mb_ptr2len)(&xp->xp_files[0][len]); | |
3703 c0 =(* mb_ptr2char)(&xp->xp_files[0][len]); | |
3704 } | |
3705 else | |
3706 #endif | |
3707 c0 = xp->xp_files[i][len]; | |
3708 for (i = 1; i < xp->xp_numfiles; ++i) | |
3709 { | |
3710 #ifdef FEAT_MBYTE | |
3711 if (has_mbyte) | |
3712 ci =(* mb_ptr2char)(&xp->xp_files[i][len]); | |
3713 else | |
3714 #endif | |
3715 ci = xp->xp_files[i][len]; | |
3698 if (p_fic && (xp->xp_context == EXPAND_DIRECTORIES | 3716 if (p_fic && (xp->xp_context == EXPAND_DIRECTORIES |
3699 || xp->xp_context == EXPAND_FILES | 3717 || xp->xp_context == EXPAND_FILES |
3700 || xp->xp_context == EXPAND_SHELLCMD | 3718 || xp->xp_context == EXPAND_SHELLCMD |
3701 || xp->xp_context == EXPAND_BUFFERS)) | 3719 || xp->xp_context == EXPAND_BUFFERS)) |
3702 { | 3720 { |
3703 if (TOLOWER_LOC(xp->xp_files[i][len]) != | 3721 if (MB_TOLOWER(c0) != MB_TOLOWER(ci)) |
3704 TOLOWER_LOC(xp->xp_files[0][len])) | |
3705 break; | 3722 break; |
3706 } | 3723 } |
3707 else if (xp->xp_files[i][len] != xp->xp_files[0][len]) | 3724 else if (c0 != ci) |
3708 break; | 3725 break; |
3709 } | 3726 } |
3710 if (i < xp->xp_numfiles) | 3727 if (i < xp->xp_numfiles) |
3711 { | 3728 { |
3712 if (!(options & WILD_NO_BEEP)) | 3729 if (!(options & WILD_NO_BEEP)) |
3713 vim_beep(BO_WILD); | 3730 vim_beep(BO_WILD); |
3714 break; | 3731 break; |
3715 } | 3732 } |
3716 } | 3733 } |
3734 | |
3717 ss = alloc((unsigned)len + 1); | 3735 ss = alloc((unsigned)len + 1); |
3718 if (ss) | 3736 if (ss) |
3719 vim_strncpy(ss, xp->xp_files[0], (size_t)len); | 3737 vim_strncpy(ss, xp->xp_files[0], (size_t)len); |
3720 findex = -1; /* next p_wc gets first one */ | 3738 findex = -1; /* next p_wc gets first one */ |
3721 } | 3739 } |