diff --git a/src/nvim/regexp.c b/src/nvim/regexp.c index 3b63c6ec8f..5074e3a8d5 100644 --- a/src/nvim/regexp.c +++ b/src/nvim/regexp.c @@ -1759,7 +1759,7 @@ static int cstrncmp(char *s1, char *s2, int *n) int n1 = *n; // count the number of characters for byte-length of s1 while (n1 > 0 && *p != NUL) { - n1 -= utfc_ptr2len(s1); + n1 -= utfc_ptr2len(p); MB_PTR_ADV(p); n2++; } diff --git a/test/old/testdir/test_regexp_utf8.vim b/test/old/testdir/test_regexp_utf8.vim index f5ec0b77d2..272d3d535e 100644 --- a/test/old/testdir/test_regexp_utf8.vim +++ b/test/old/testdir/test_regexp_utf8.vim @@ -363,6 +363,12 @@ func Run_regexp_ignore_case() call assert_equal('iIx', substitute('iIİ', '\c\(\%u0130\)', 'x', 'g')) call assert_equal('iIx', substitute('iIİ', '\c\([\u0130]\)', 'x', 'g')) call assert_equal('iIx', substitute('iIİ', '\c\([\u012f-\u0131]\)', 'x', 'g')) + + " Ignoring case in a literal string that starts with a character longer + " than a following one must still match. + call assert_equal('Über', matchstr('Überraschung', '\cüber')) + call assert_equal('Ünder', matchstr('Ünderdog', '\cünder')) + call assert_equal('αaaa', matchstr('αaaaa', '\cαaaa')) endfunc func Test_regexp_ignore_case()