@@ -1300,7 +1300,7 @@ H.state_advance = function(opts)
13001300 H .state .timer :stop ()
13011301 local show_immediately = H .is_valid_win (H .state .win_id ) or H .state .is_after_postkeys
13021302 local delay = show_immediately and 0 or config_window .delay
1303- H .state .timer :start (delay , 0 , function () H .window_update (opts .scroll_to_start ) end )
1303+ H .state .timer :start (delay , 0 , function () H .window_update (opts .same_content ) end )
13041304
13051305 -- Reset postkeys right now to not flicker when trying to close window during
13061306 -- "not querying" check
@@ -1318,7 +1318,7 @@ H.state_advance = function(opts)
13181318 local is_scroll_up = key == H .replace_termcodes (config_window .scroll_up )
13191319 if is_scroll_down or is_scroll_up then
13201320 H .window_scroll (is_scroll_down and H .keys .ctrl_d or H .keys .ctrl_u )
1321- return H .state_advance ({ scroll_to_start = false })
1321+ return H .state_advance ({ same_content = true })
13221322 end
13231323
13241324 if key == H .keys .bs then
@@ -1505,31 +1505,33 @@ H.query_to_keys = function(query) return table.concat(query, '') end
15051505H .query_to_title = function (query ) return H .keytrans (H .query_to_keys (query )) end
15061506
15071507-- Window ---------------------------------------------------------------------
1508- H .window_update = vim .schedule_wrap (function (scroll_to_start )
1508+ H .window_update = vim .schedule_wrap (function (same_content )
15091509 -- Make sure that outdated windows are not shown
15101510 if # H .state .query == 0 then return H .window_close () end
1511+ local win_id = H .state .win_id
15111512
15121513 -- Close window if it is not in current tabpage (as only window is tracked)
1513- local is_different_tabpage = H .is_valid_win (H . state . win_id )
1514- and vim .api .nvim_win_get_tabpage (H . state . win_id ) ~= vim .api .nvim_get_current_tabpage ()
1514+ local is_different_tabpage = H .is_valid_win (win_id )
1515+ and vim .api .nvim_win_get_tabpage (win_id ) ~= vim .api .nvim_get_current_tabpage ()
15151516 if is_different_tabpage then H .window_close () end
15161517
15171518 -- Create-update buffer showing clues
1518- H .state .buf_id = H .buffer_update ()
1519+ if not same_content then H .state .buf_id = H .buffer_update () end
15191520
15201521 -- Create-update window showing buffer
15211522 local win_config = H .window_get_config ()
1522- if not H .is_valid_win (H .state .win_id ) then
1523- H .state .win_id = H .window_open (win_config )
1523+ if not H .is_valid_win (win_id ) then
1524+ win_id = H .window_open (win_config )
1525+ H .state .win_id = win_id
15241526 else
1525- vim .api .nvim_win_set_config (H .state .win_id , win_config )
1527+ vim .api .nvim_win_set_config (win_id , win_config )
1528+ vim .wo [win_id ].list = true
15261529 end
15271530
15281531 -- Make scroll not persist. NOTE: Don't use 'normal! gg' inside target window
15291532 -- as it resets `v:count` and `v:register` which results into invalid keys
15301533 -- reproduction in Operator-pending mode.
1531- if scroll_to_start == nil then scroll_to_start = true end
1532- if scroll_to_start then vim .api .nvim_win_set_cursor (H .state .win_id , { 1 , 0 }) end
1534+ if not same_content then vim .api .nvim_win_set_cursor (win_id , { 1 , 0 }) end
15331535
15341536 -- Add redraw because Neovim won't do it when `getcharstr()` is active
15351537 vim .cmd (' redraw' )
0 commit comments