File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -11,7 +11,7 @@ local ctx
1111--- @field bufnr integer
1212--- @field bname string
1313--- @field winid integer
14- --- @field last_winid integer
14+ --- @field last_winid integer ?
1515--- @field alt_bufnr integer
1616--- @field tabnr integer
1717--- @field tabh integer
@@ -52,7 +52,15 @@ M.refresh = function(opts)
5252 bufnr = vim .api .nvim_get_current_buf (),
5353 bname = vim .api .nvim_buf_get_name (0 ),
5454 winid = vim .api .nvim_get_current_win (),
55- last_winid = vim .fn .win_getid (vim .fn .winnr (" #" )),
55+ last_winid = (function ()
56+ local last_winnr = vim .fn .winnr (" #" )
57+ return last_winnr > 0
58+ -- we use this to restore the last window
59+ -- ignore if both current and last are equal
60+ and last_winnr ~= vim .fn .winnr ()
61+ and vim .fn .win_getid (last_winnr )
62+ or nil
63+ end )(),
5664 alt_bufnr = vim .fn .bufnr (" #" ),
5765 tabnr = vim .fn .tabpagenr (),
5866 tabh = vim .api .nvim_win_get_tabpage (0 ),
You can’t perform that action at this time.
0 commit comments