Skip to content

Commit 4e9f16d

Browse files
anntzerchrisbra
authored andcommitted
runtime(rst): Correctly end nested comments
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>
1 parent 47949b4 commit 4e9f16d

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

runtime/syntax/rst.vim

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,8 @@ syn cluster rstDirectives contains=rstFootnote,rstCitation,
5252
\ rstHyperlinkTarget,rstExDirective
5353

5454
syn match rstExplicitMarkup '^\s*\.\.\_s'
55-
\ nextgroup=@rstDirectives,rstComment,rstSubstitutionDefinition
55+
\ nextgroup=@rstDirectives,rstSubstitutionDefinition
56+
\ contains=rstComment
5657

5758
" "Simple reference names are single words consisting of alphanumerics plus
5859
" isolated (no two adjacent) internal hyphens, underscores, periods, colons
@@ -61,10 +62,10 @@ let s:ReferenceName = '[[:alnum:]]\%([-_.:+]\?[[:alnum:]]\+\)*'
6162

6263
syn keyword rstTodo contained FIXME TODO XXX NOTE
6364

64-
execute 'syn region rstComment contained' .
65-
\ ' start=/.*/'
66-
\ ' skip=+^$+' .
67-
\ ' end=/^\s\@!/ contains=rstTodo'
65+
syn region rstComment
66+
\ start='\v^\z(\s*)\.\.(\_s+[\[|_]|\_s+.*::)@!' skip=+^$+ end=/^\(\z1 \)\@!/
67+
\ contains=@Spell,rstTodo
68+
6869

6970
execute 'syn region rstFootnote contained matchgroup=rstDirective' .
7071
\ ' start=+\[\%(\d\+\|#\%(' . s:ReferenceName . '\)\=\|\*\)\]\_s+' .

0 commit comments

Comments
 (0)