]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
runtime(rst): Correctly end nested comments
authorAntony Lee <anntzer.lee@gmail.com>
Mon, 13 Oct 2025 18:28:58 +0000 (18:28 +0000)
committerChristian Brabandt <cb@256bit.org>
Mon, 13 Oct 2025 18:28:58 +0000 (18:28 +0000)
Previously, a comment in a directive block would incorrectly mark
all subsequent lines in the directive block as comment, because the
syn-region did not check the leading indent.

related: #18566

Signed-off-by: Antony Lee <anntzer.lee@gmail.com>
Signed-off-by: Marshall Ward <marshall.ward@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
runtime/syntax/rst.vim

index 4b9379f5e6ceaece7d793759b34a9c336aa88e21..8094d8771b7fdec77ed8baf095ab822feb619ad3 100644 (file)
@@ -52,7 +52,8 @@ syn cluster rstDirectives           contains=rstFootnote,rstCitation,
       \ rstHyperlinkTarget,rstExDirective
 
 syn match   rstExplicitMarkup       '^\s*\.\.\_s'
-      \ nextgroup=@rstDirectives,rstComment,rstSubstitutionDefinition
+      \ nextgroup=@rstDirectives,rstSubstitutionDefinition
+      \ contains=rstComment
 
 " "Simple reference names are single words consisting of alphanumerics plus
 " isolated (no two adjacent) internal hyphens, underscores, periods, colons
@@ -61,10 +62,10 @@ let s:ReferenceName = '[[:alnum:]]\%([-_.:+]\?[[:alnum:]]\+\)*'
 
 syn keyword     rstTodo             contained FIXME TODO XXX NOTE
 
-execute 'syn region rstComment contained' .
-      \ ' start=/.*/'
-      \ ' skip=+^$+' .
-      \ ' end=/^\s\@!/ contains=rstTodo'
+syn region rstComment
+      \ start='\v^\z(\s*)\.\.(\_s+[\[|_]|\_s+.*::)@!' skip=+^$+ end=/^\(\z1   \)\@!/
+      \ contains=@Spell,rstTodo
+
 
 execute 'syn region rstFootnote contained matchgroup=rstDirective' .
       \ ' start=+\[\%(\d\+\|#\%(' . s:ReferenceName . '\)\=\|\*\)\]\_s+' .