]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 8.2.2177: pattern "^" does not match if first character is combining v8.2.2177
authorBram Moolenaar <Bram@vim.org>
Mon, 21 Dec 2020 13:54:32 +0000 (14:54 +0100)
committerBram Moolenaar <Bram@vim.org>
Mon, 21 Dec 2020 13:54:32 +0000 (14:54 +0100)
Problem:    Pattern "^" does not match if the first character in the line is
            combining. (Rene Kita)
Solution:   Do accept a match at the start of the line. (closes #6963)

src/regexp_nfa.c
src/testdir/test_regexp_utf8.vim
src/version.c

index cbfed49b59c8c0527af685e5a59c5f4610ee451e..6182f58cdb42b33034efa4b348a37c2a0c8e61df 100644 (file)
@@ -5754,9 +5754,11 @@ nfa_regmatch(
            {
            case NFA_MATCH:
              {
-               // If the match ends before a composing characters and
-               // rex.reg_icombine is not set, that is not really a match.
-               if (enc_utf8 && !rex.reg_icombine && utf_iscomposing(curc))
+               // If the match is not at the start of the line, ends before a
+               // composing characters and rex.reg_icombine is not set, that
+               // is not really a match.
+               if (enc_utf8 && !rex.reg_icombine
+                            && rex.input != rex.line && utf_iscomposing(curc))
                    break;
 
                nfa_match = TRUE;
index a1c06b4af6ad7ed163fe5ad7e9419a2bacec9bc6..78702407c4348b18ceb42f824f660ca4eca9724a 100644 (file)
@@ -501,4 +501,15 @@ func Test_search_with_end_offset()
   close!
 endfunc
 
+" Check that "^" matches even when the line starts with a combining char
+func Test_match_start_of_line_combining()
+  new
+  call setline(1, ['', "\u05ae", ''])
+  exe "normal gg/^\<CR>"
+  call assert_equal(2, getcurpos()[1])
+  bwipe!
+endfunc
+
+
+
 " vim: shiftwidth=2 sts=2 expandtab
index 5ed39fe5346ae3278e5b2cbf72087511e6f41a9e..05f08e5c7a7a84e35994825f1f41255353194c9b 100644 (file)
@@ -750,6 +750,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    2177,
 /**/
     2176,
 /**/