]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.1.1190: C indentation does not detect multibyte labels v9.1.1190
authorAnttoni Erkkilä <anttoni.erkkila@protonmail.com>
Sun, 9 Mar 2025 15:07:15 +0000 (16:07 +0100)
committerChristian Brabandt <cb@256bit.org>
Sun, 9 Mar 2025 15:07:15 +0000 (16:07 +0100)
Problem:  C indentation does not detect multibyte labels
Solution: Correctly skip over multibyte characters
          (Anttoni Erkkilä)

closes: #16770

Signed-off-by: Anttoni Erkkilä <anttoni.erkkila@protonmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
src/cindent.c
src/testdir/test_indent.vim
src/version.c

index cf18441f608421f8d25d14c2815595cee70207e4..2414b3fad5b2243aebb9baa18746e4f4b10473ab 100644 (file)
@@ -405,7 +405,12 @@ cin_islabel_skip(char_u **s)
        return FALSE;
 
     while (vim_isIDc(**s))
-       (*s)++;
+    {
+        if (has_mbyte)
+            (*s) += (*mb_ptr2len)(*s);
+        else
+            (*s)++;
+    }
 
     *s = cin_skipcomment(*s);
 
index 0f0f9da8beb280d8f0dd8db7eb0eb0bc5ca89044..57f5206e7749c9d72035dd286c1052bae3b2a3f2 100644 (file)
@@ -109,6 +109,19 @@ func Test_preproc_indent()
   close!
 endfunc
 
+func Test_userlabel_indent()
+  new
+  call setline(1, ['{', 'label:'])
+  normal GV=
+  call assert_equal('label:', getline(2))
+
+  call setline(2, 'läbél:')
+  normal GV=
+  call assert_equal('läbél:', getline(2))
+
+  close!
+endfunc
+
 " Test for 'copyindent'
 func Test_copyindent()
   new
index af03cd9dd5a38f66a0a25bfe522e432dfbbcfc0d..fa05cd1741a7d17c9246f59aad969a0afc112388 100644 (file)
@@ -704,6 +704,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1190,
 /**/
     1189,
 /**/