@@ -472,7 +472,7 @@ T['Highlighters']['allows submatch in `pattern`'] = function()
472472 set_lines ({ ' abcd' , ' xabcd' , ' xxabcd' , ' xxabcdxx' })
473473
474474 local validate = function (pattern )
475- child .lua ([[ require(' mini.hipatterns' ).disable()]] )
475+ child .lua (' require(" mini.hipatterns" ).disable()' )
476476 local config = {
477477 highlighters = { abcd = { pattern = pattern , group = ' Error' } },
478478 delay = test_config .delay ,
@@ -495,6 +495,29 @@ T['Highlighters']['allows submatch in `pattern`'] = function()
495495 validate (' xx()ab()c()d()' )
496496end
497497
498+ T [' Highlighters' ][' works with overlapping matches' ] = function ()
499+ local validate = function (pattern , ref_ranges )
500+ child .lua (' require("mini.hipatterns").disable()' )
501+ local config = {
502+ highlighters = { x = { pattern = pattern , group = ' Error' } },
503+ delay = test_config .delay ,
504+ }
505+ enable (0 , config )
506+
507+ sleep (test_config .delay .text_change + small_time )
508+ local ranges = vim .tbl_map (function (e ) return { e .from_col , e .to_col } end , get_hipatterns_extmarks (0 , { ' x' }))
509+ eq (ranges , ref_ranges )
510+ end
511+
512+ set_lines ({ string.rep (' x' , 7 ) })
513+
514+ -- Should behave similarly to how `/` with `\zs` and `\ze` works
515+ validate (' xxx' , { { 1 , 3 }, { 4 , 6 } })
516+ validate (' ()xx()x' , { { 1 , 2 }, { 3 , 4 }, { 5 , 6 } })
517+ validate (' x()xx()' , { { 2 , 3 }, { 5 , 6 } })
518+ validate (' x()x()x' , { { 2 , 2 }, { 4 , 4 }, { 6 , 6 } })
519+ end
520+
498521T [' Highlighters' ][' allows frontier pattern in `pattern`' ] = function ()
499522 local config = {
500523 highlighters = { abcd = { pattern = ' %f[%w]abcd%f[%W]' , group = ' Error' } },
0 commit comments