@@ -561,17 +561,7 @@ function Previewer.base:scroll(direction)
561561
562562 if not input then return end
563563
564- if direction == " reset" then
565- pcall (api .nvim_win_call , preview_winid , function ()
566- -- for some reason 'nvim_win_set_cursor'
567- -- only moves forward, so set to (1,0) first
568- api .nvim_win_set_cursor (0 , { 1 , 0 })
569- if self .orig_pos then
570- api .nvim_win_set_cursor (0 , self .orig_pos )
571- end
572- utils .zz ()
573- end )
574- else
564+ local scroll = function ()
575565 pcall (api .nvim_win_call , preview_winid , function ()
576566 vim .cmd ([[ norm! ]] .. input )
577567 -- `zb` at bottom?
@@ -585,6 +575,28 @@ function Previewer.base:scroll(direction)
585575 end )
586576 end
587577
578+ if direction == " reset" then
579+ pcall (api .nvim_win_call , preview_winid , function ()
580+ -- for some reason 'nvim_win_set_cursor'
581+ -- only moves forward, so set to (1,0) first
582+ api .nvim_win_set_cursor (0 , { 1 , 0 })
583+ if self .orig_pos then
584+ api .nvim_win_set_cursor (0 , self .orig_pos )
585+ end
586+ utils .zz ()
587+ end )
588+ else
589+ if utils .is_term_buffer (self .preview_bufnr ) and api .nvim_get_mode ().mode == " t" then
590+ vim .cmd .stopinsert ()
591+ vim .schedule (function ()
592+ scroll ()
593+ vim .cmd .startinsert ()
594+ end )
595+ else
596+ scroll ()
597+ end
598+ end
599+
588600 -- 'cursorline' is effectively our match highlight. Once the
589601 -- user scrolls, the highlight is no longer relevant (#462).
590602 -- Conditionally toggle 'cursorline' based on cursor position
0 commit comments