]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
runtime(comment): handle special chars ^$[ robustly
authorMaxim Kim <habamax@gmail.com>
Fri, 13 Jun 2025 18:18:50 +0000 (20:18 +0200)
committerChristian Brabandt <cb@256bit.org>
Fri, 13 Jun 2025 18:18:50 +0000 (20:18 +0200)
Make sure comment toggling works when 'commentstring' contains
any of the following regex special characters by escaping them:

^ $ [

closes: #17537

Signed-off-by: Maxim Kim <habamax@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
runtime/pack/dist/opt/comment/autoload/comment.vim

index f678a98fac19b0ef6c614946da17a8289990b29c..74e091c358d471000a0c35bf6f42f00a973072ef 100644 (file)
@@ -1,7 +1,7 @@
 vim9script
 
 # Maintainer: Maxim Kim <habamax@gmail.com>
-# Last Update: 2025-06-12
+# Last Update: 2025-06-13
 #
 # Toggle comments
 # Usage:
@@ -19,7 +19,7 @@ export def Toggle(...args: list<string>): string
     if empty(&cms) || !&ma | return '' | endif
     var cms = substitute(substitute(&cms, '\S\zs%s\s*', ' %s', ''), '%s\ze\S', '%s ', '')
     var [lnum1, lnum2] = [line("'["), line("']")]
-    var cms_l = split(escape(cms, '*.\'), '\s*%s\s*')
+    var cms_l = split(escape(cms, '*.\^$['), '\s*%s\s*')
 
     var first_col = indent(lnum1)
     var start_col = getpos("'[")[2] - 1