]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.2.0718: :syn sync without an argument also lists syntax cluster v9.2.0718
authorDmytro Meleshko <dmytro.meleshko@gmail.com>
Wed, 24 Jun 2026 17:51:22 +0000 (17:51 +0000)
committerChristian Brabandt <cb@256bit.org>
Wed, 24 Jun 2026 17:52:56 +0000 (17:52 +0000)
Problem:  :syn sync without an argument also lists every defined cluster
Solution: Fix control flow in syn_cmd_list() so that only the syncing
          items are printed when this function gets called by :syn sync.
          (dmitmel)

closes: #20614

Signed-off-by: Dmytro Meleshko <dmytro.meleshko@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
src/po/vim.pot
src/syntax.c
src/testdir/test_syntax.vim
src/version.c

index bbbf9f0cc20a80cf56d551ee73172affd41956bf..131e52457fb7d9f2502dc074bee803d91299859a 100644 (file)
@@ -8,7 +8,7 @@ msgid ""
 msgstr ""
 "Project-Id-Version: Vim\n"
 "Report-Msgid-Bugs-To: vim-dev@vim.org\n"
-"POT-Creation-Date: 2026-06-22 19:36+0000\n"
+"POT-Creation-Date: 2026-06-24 17:52+0000\n"
 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
 "Language-Team: LANGUAGE <LL@li.org>\n"
@@ -3109,26 +3109,26 @@ msgstr ""
 msgid "syncing on C-style comments"
 msgstr ""
 
-msgid "no syncing"
+msgid ""
+"\n"
+"--- Syntax sync items ---"
 msgstr ""
 
-msgid "syncing starts at the first line"
+msgid ""
+"\n"
+"syncing on items"
 msgstr ""
 
-msgid "syncing starts "
+msgid "no syncing"
 msgstr ""
 
-msgid " lines before top line"
+msgid "syncing starts at the first line"
 msgstr ""
 
-msgid ""
-"\n"
-"--- Syntax sync items ---"
+msgid "syncing starts "
 msgstr ""
 
-msgid ""
-"\n"
-"syncing on items"
+msgid " lines before top line"
 msgstr ""
 
 msgid ""
index 4333c3183929cee592493ba23036864ec7872dc4..6f22d9ece6c557bc4212da33fe97d3f49fbfd8ea 100644 (file)
@@ -3834,9 +3834,22 @@ syn_cmd_list(
            msg_puts(_("syncing on C-style comments"));
            syn_lines_msg();
            syn_match_msg();
-           return;
        }
-       else if (!(curwin->w_s->b_syn_sync_flags & SF_MATCH))
+       else if (curwin->w_s->b_syn_sync_flags & SF_MATCH)
+       {
+           msg_puts_title(_("\n--- Syntax sync items ---"));
+           if (curwin->w_s->b_syn_sync_minlines > 0
+               || curwin->w_s->b_syn_sync_maxlines > 0
+               || curwin->w_s->b_syn_sync_linebreaks > 0)
+           {
+               msg_puts(_("\nsyncing on items"));
+               syn_lines_msg();
+               syn_match_msg();
+           }
+           for (id = 1; id <= highlight_num_groups() && !got_int; ++id)
+               syn_list_one(id, syncing, FALSE);
+       }
+       else
        {
            if (curwin->w_s->b_syn_sync_minlines == 0)
                msg_puts(_("no syncing"));
@@ -3852,20 +3865,11 @@ syn_cmd_list(
                }
                syn_match_msg();
            }
-           return;
-       }
-       msg_puts_title(_("\n--- Syntax sync items ---"));
-       if (curwin->w_s->b_syn_sync_minlines > 0
-               || curwin->w_s->b_syn_sync_maxlines > 0
-               || curwin->w_s->b_syn_sync_linebreaks > 0)
-       {
-           msg_puts(_("\nsyncing on items"));
-           syn_lines_msg();
-           syn_match_msg();
        }
+       return;
     }
-    else
-       msg_puts_title(_("\n--- Syntax items ---"));
+
+    msg_puts_title(_("\n--- Syntax items ---"));
     if (ends_excmd2(eap->cmd, arg))
     {
        /*
index 170e2e3b934621bf42fc19c91ee9730913560a2d..d4a81dd6569d0cdcca53ccc5b73cf9ff34a738de 100644 (file)
@@ -419,6 +419,25 @@ func Test_syn_sync()
   call assert_match('SyncHere', execute('syntax sync'))
   syn sync clear
   call assert_notmatch('SyncHere', execute('syntax sync'))
+
+  syn sync minlines=10
+  syntax cluster xmlStuff contains=xmlGroup1,xmlGroup2
+  syntax region xmlComment start=/<!--/ end=/-->/ keepend contains=@Spell
+  syntax sync match xmlSync1 grouphere xmlComment /<!--/
+  syntax sync match xmlSync2 groupthere NONE /-->/
+  syntax cluster xmlAll contains=ALL
+  let out = execute('syntax sync')
+  call assert_match('xmlSync1', out)
+  call assert_match('xmlSync2', out)
+  call assert_match('grouphere xmlComment', out)
+  call assert_match('groupthere NONE', out)
+  call assert_notmatch('xmlStuff', out)
+  call assert_notmatch('xmlAll', out)
+  call assert_notmatch('cluster', out)
+  call assert_notmatch('keepend', out)
+  " should output 4 lines: 1 header + 3 syn sync lines
+  call assert_equal(4, len(split(out, '\n')))
+
   syn clear
 endfunc
 
index 72f154f3e6fafd268db3cf8d32cd798004778879..7fd7b6b8013710865811f3229174bba22e26852e 100644 (file)
@@ -759,6 +759,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    718,
 /**/
     717,
 /**/