diff options
author | Bram Moolenaar <Bram@vim.org> | 2015-11-19 19:00:05 +0100 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2015-11-19 19:00:05 +0100 |
commit | 4f8fa1633cdfbd09a41160c8480fe67c198067e9 (patch) | |
tree | 8dba743f40ae9754db879315d24fd4737a347b31 /src/ex_getln.c | |
parent | a0ed84a26897c994512873a895b9fc54e90c6845 (diff) |
patch 7.4.926v7.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)
Diffstat (limited to 'src/ex_getln.c')
-rw-r--r-- | src/ex_getln.c | 28 |
1 files changed, 23 insertions, 5 deletions
diff --git a/src/ex_getln.c b/src/ex_getln.c index 5d7ea2009f..33d612bfa8 100644 --- a/src/ex_getln.c +++ b/src/ex_getln.c @@ -3691,20 +3691,37 @@ ExpandOne(xp, str, orig, options, mode) /* Find longest common part */ if (mode == WILD_LONGEST && xp->xp_numfiles > 0) { - for (len = 0; xp->xp_files[0][len]; ++len) + int mb_len = 1; + int c0, ci; + + for (len = 0; xp->xp_files[0][len]; len += mb_len) { - for (i = 0; i < xp->xp_numfiles; ++i) +#ifdef FEAT_MBYTE + if (has_mbyte) { + mb_len = (*mb_ptr2len)(&xp->xp_files[0][len]); + c0 =(* mb_ptr2char)(&xp->xp_files[0][len]); + } + else +#endif + c0 = xp->xp_files[i][len]; + for (i = 1; i < xp->xp_numfiles; ++i) + { +#ifdef FEAT_MBYTE + if (has_mbyte) + ci =(* mb_ptr2char)(&xp->xp_files[i][len]); + else +#endif + ci = xp->xp_files[i][len]; if (p_fic && (xp->xp_context == EXPAND_DIRECTORIES || xp->xp_context == EXPAND_FILES || xp->xp_context == EXPAND_SHELLCMD || xp->xp_context == EXPAND_BUFFERS)) { - if (TOLOWER_LOC(xp->xp_files[i][len]) != - TOLOWER_LOC(xp->xp_files[0][len])) + if (MB_TOLOWER(c0) != MB_TOLOWER(ci)) break; } - else if (xp->xp_files[i][len] != xp->xp_files[0][len]) + else if (c0 != ci) break; } if (i < xp->xp_numfiles) @@ -3714,6 +3731,7 @@ ExpandOne(xp, str, orig, options, mode) break; } } + ss = alloc((unsigned)len + 1); if (ss) vim_strncpy(ss, xp->xp_files[0], (size_t)len); |