@@ -38,7 +38,7 @@ M.active = nil
3838
3939--- @class  CmdlineFormat 
4040--- @field  kind  string 
41- --- @field  pattern ? string 
41+ --- @field  pattern ? string | string[] 
4242--- @field  view  string 
4343--- @field  conceal ? boolean 
4444--- @field  icon ? string 
@@ -75,22 +75,31 @@ function Cmdline:get_format()
7575  end 
7676  local  line  =  self .state .firstc  ..  self :get ()
7777
78-   --- @type  table<string ,  CmdlineFormat> 
79-   local  formats  =  vim .tbl_values (vim .tbl_filter (function (f )
80-     return  f .pattern 
81-   end , Config .options .cmdline .format ))
82-   table.sort (formats , function (a , b )
83-     return  # a .pattern  >  # b .pattern 
84-   end )
85- 
86-   for  _ , format  in  pairs (formats ) do 
87-     local  from , to  =  line :find (format .pattern )
88-     --  if match and cmdline pos is visible
89-     if  from  and  self .state .pos  >=  to  -  1  then 
90-       self .offset  =  format .conceal  and  to  or  0 
91-       return  format 
78+   --- @type  { offset : number ,  format :  CmdlineFormat } [] 
79+   local  ret  =  {}
80+ 
81+   for  _ , format  in  pairs (Config .options .cmdline .format ) do 
82+     local  patterns  =  type (format .pattern ) ==  " table"  and  format .pattern  or  { format .pattern  }
83+     --- @cast  patterns  string[] 
84+     for  _ , pattern  in  ipairs (patterns ) do 
85+       local  from , to  =  line :find (pattern )
86+       --  if match and cmdline pos is visible
87+       if  from  and  self .state .pos  >=  to  -  1  then 
88+         ret [# ret  +  1 ] =  {
89+           offset  =  format .conceal  and  to  or  0 ,
90+           format  =  format ,
91+         }
92+       end 
9293    end 
9394  end 
95+   table.sort (ret , function (a , b )
96+     return  a .offset  >  b .offset 
97+   end )
98+   local  format  =  ret [1 ]
99+   if  format  then 
100+     self .offset  =  format .offset 
101+     return  format .format 
102+   end 
94103  self .offset  =  0 
95104  return  {
96105    kind  =  self .state .firstc ,
0 commit comments