@@ -467,6 +467,15 @@ T['Evaluate']['works in Normal mode for line'] = function()
467467 validate_edit ({ ' 1 + 1' , ' 1 + 2' }, { 1 , 0 }, { ' g==' , ' j' , ' .' }, { ' 2' , ' 3' }, { 2 , 0 })
468468end
469469
470+ T [' Evaluate' ][' works with empty textobject/motion' ] = function ()
471+ child .api .nvim_set_keymap (' o' , ' w' , ' <Cmd><CR>' , {})
472+ child .lua (' _G.x = 1' )
473+ set_lines ({ ' xxx' })
474+ set_cursor (1 , 1 )
475+ type_keys (' g=' , ' w' )
476+ eq (get_lines (), { ' xxx' })
477+ end
478+
470479T [' Evaluate' ][' works in Visual mode' ] = function ()
471480 -- Charwise
472481 validate_edit ({ ' 1 + 1 = (1 + 1)' }, { 1 , 8 }, { ' va)' , ' g=' }, { ' 1 + 1 = 2' }, { 1 , 8 })
@@ -805,6 +814,31 @@ T['Exchange']['works with `[count]` in Normal mode for line'] = function()
805814 )
806815end
807816
817+ T [' Exchange' ][' works with empty textobject/motion' ] = function ()
818+ child .api .nvim_set_keymap (' o' , ' w' , ' <Cmd><CR>' , {})
819+
820+ -- On step one
821+ set_lines ({ ' xxx' , ' yyy' })
822+ set_cursor (1 , 1 )
823+ type_keys (' gx' , ' w' )
824+ eq (child .fn .maparg (' <C-c>' ), ' ' )
825+ -- - Should ignore previous time and treat this as step one
826+ type_keys (' j' , ' gx' , ' $' )
827+ eq (get_lines (), { ' xxx' , ' yyy' })
828+ type_keys (' k' , ' gx' , ' $' )
829+ eq (get_lines (), { ' xyy' , ' yxx' })
830+
831+ -- On step two
832+ set_lines ({ ' xxx' , ' yyy' })
833+ set_cursor (1 , 1 )
834+ type_keys (' gx' , ' iw' )
835+ -- - Should ignore this one while still allowing proper step two
836+ type_keys (' jl' , ' gx' , ' w' )
837+ eq (get_lines (), { ' xxx' , ' yyy' })
838+ type_keys (' gx' , ' $' )
839+ eq (get_lines (), { ' yy' , ' yxxx' })
840+ end
841+
808842T [' Exchange' ][' works in Visual mode' ] = function ()
809843 -- Charwise from - Charwise to
810844 validate_edit1d (' aa bb' , 0 , { ' viwgx' , ' w' , ' viwgx' }, ' bb aa' , 3 )
@@ -1366,6 +1400,14 @@ T['Multiply']['works with `cmdheight=0`'] = function()
13661400 child .expect_screenshot ({ redraw = false })
13671401end
13681402
1403+ T [' Multiply' ][' works with empty textobject/motion' ] = function ()
1404+ child .api .nvim_set_keymap (' o' , ' w' , ' <Cmd><CR>' , {})
1405+ set_lines ({ ' xxx' })
1406+ set_cursor (1 , 1 )
1407+ type_keys (' gm' , ' w' )
1408+ eq (get_lines (), { ' xxx' })
1409+ end
1410+
13691411T [' Multiply' ][' works in Visual mode' ] = function ()
13701412 validate_edit1d (' aa bb' , 0 , { ' viw' , ' gm' }, ' aaaa bb' , 2 )
13711413
@@ -1786,6 +1828,15 @@ T['Replace']['works with `[count]` in Normal mode for line'] = function()
17861828 )
17871829end
17881830
1831+ T [' Replace' ][' works with empty textobject/motion' ] = function ()
1832+ child .api .nvim_set_keymap (' o' , ' w' , ' <Cmd><CR>' , {})
1833+ set_lines ({ ' xxx' , ' yyy' })
1834+ set_cursor (1 , 1 )
1835+ type_keys (' yiw' , ' jl' )
1836+ type_keys (' gr' , ' w' )
1837+ eq (get_lines (), { ' xxx' , ' yyy' })
1838+ end
1839+
17891840T [' Replace' ][' works in Visual mode' ] = function ()
17901841 -- Charwise selection
17911842 validate_edit ({ ' aa bb' }, { 1 , 0 }, { ' yiw' , ' w' , ' viw' , ' gr' }, { ' aa aa' }, { 1 , 3 })
@@ -2184,6 +2235,14 @@ T['Sort']['works in Normal mode for line'] = function()
21842235 validate_edit ({ ' t, r, s' , ' c, a, b' }, { 1 , 0 }, { ' gss' , ' j' , ' .' }, { ' r, s, t' , ' a, b, c' }, { 2 , 0 })
21852236end
21862237
2238+ T [' Sort' ][' works with empty textobject/motion' ] = function ()
2239+ child .api .nvim_set_keymap (' o' , ' w' , ' <Cmd><CR>' , {})
2240+ set_lines ({ ' fedcba' })
2241+ set_cursor (1 , 1 )
2242+ type_keys (' gs' , ' w' )
2243+ eq (get_lines (), { ' fedcba' })
2244+ end
2245+
21872246T [' Sort' ][' works in Visual mode' ] = function ()
21882247 -- Charwise region
21892248 validate_edit1d (' c, a, b' , 0 , { ' v$' , ' gs' }, ' a, b, c' , 0 )
0 commit comments