@@ -14,10 +14,17 @@ export def ZipLists(l1: list<any>, l2: list<any>): list<list<any>>
1414 return map (range (min_len), $ ' [{l1}[v:val], {l2}[v:val]]' )
1515enddef
1616
17- export def RegexList2RegexOR (regex_list: list <string> ): string
18- # Valid only for very- magic regex.
19- return regex_list- >map ((_, val) = > substitute (val, ' ^\(\\v\)' , ' ' , ' ' ))
17+ export def RegexList2RegexOR (regex_list: list <string> ,
18+ very_magic: bool = false): string
19+
20+ var result = ' '
21+ if very_magic
22+ result = regex_list- >map ((_, val) = > substitute (val, ' ^\(\\v\)' , ' ' , ' ' ))
2023 - >join (' |' )- >printf (' \v(%s)' )
24+ else
25+ result = regex_list- >join (' \|' )- >printf (' \(%s\)' )
26+ endif
27+ return result
2128enddef
2229
2330export def GetTextObject (textobject: string ): string
@@ -208,7 +215,7 @@ export def g:Surround(open_delimiter: string,
208215 echom " TBD"
209216 # Overwrite everything that is in the middle
210217 var middle = strcharpart (getline (lA), cA - 1 , cB - cA)
211- - > substitute (RegexList2RegexOR (values (open_delimiters_dict)), ' ' , ' g' )
218+ - > substitute (RegexList2RegexOR (values (open_delimiters_dict), true ), ' ' , ' g' )
212219 setline (lA, toA .. middle .. fromB)
213220 elseif lB - lA == 1
214221 echom " TBD"
0 commit comments