@@ -546,6 +546,7 @@ describe('renderer.scroll_to_bottom', function()
546546 vim .api .nvim_set_current_win (input_win )
547547
548548 local winleave_count = 0
549+ local modechanged_count = 0
549550 local group = vim .api .nvim_create_augroup (' OpencodeScrollImeRegression' , { clear = true })
550551 vim .api .nvim_create_autocmd (' WinLeave' , {
551552 group = group ,
@@ -554,6 +555,21 @@ describe('renderer.scroll_to_bottom', function()
554555 winleave_count = winleave_count + 1
555556 end ,
556557 })
558+ vim .api .nvim_create_autocmd (' ModeChanged' , {
559+ group = group ,
560+ pattern = ' i:n' ,
561+ callback = function ()
562+ modechanged_count = modechanged_count + 1
563+ end ,
564+ })
565+
566+ local cmd_stub = require (' luassert.stub' )(vim , ' cmd' ).invokes (function (cmd )
567+ if cmd == ' normal! zb' then
568+ vim .api .nvim_exec_autocmds (' ModeChanged' , { pattern = ' i:n' , modeline = false })
569+ return
570+ end
571+ return vim .api .nvim_cmd (vim .api .nvim_parse_cmd (cmd , {}), {})
572+ end )
557573
558574 vim .api .nvim_win_set_height (win , 5 )
559575 vim .api .nvim_win_set_cursor (win , { 1 , 0 })
@@ -563,8 +579,11 @@ describe('renderer.scroll_to_bottom', function()
563579
564580 assert .equals (input_win , vim .api .nvim_get_current_win ())
565581 assert .equals (0 , winleave_count )
582+ assert .equals (0 , modechanged_count )
566583 assert .equals (50 , vim .api .nvim_win_get_cursor (win )[1 ])
584+ assert .stub (cmd_stub ).was_called_with (' normal! zb' )
567585
586+ cmd_stub :revert ()
568587 config .values .ui .output .always_scroll_to_bottom = false
569588 pcall (vim .api .nvim_del_augroup_by_id , group )
570589 end )
0 commit comments