From a78af4ce9989e76734eefefa8ac29852ae695250 Mon Sep 17 00:00:00 2001 From: Arnon Keereena Date: Mon, 14 Jul 2025 09:08:55 +0700 Subject: [PATCH] Fix bugs where the file picker windows disappear on @file mentions (#2442) Co-authored-by: Arnon Keereena --- lua/avante/utils/init.lua | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lua/avante/utils/init.lua b/lua/avante/utils/init.lua index a089205..050167d 100644 --- a/lua/avante/utils/init.lua +++ b/lua/avante/utils/init.lua @@ -741,10 +741,12 @@ function M.throttle(func, delay) end function M.winline(winid) - local current_win = api.nvim_get_current_win() - api.nvim_set_current_win(winid) - local line = fn.winline() - api.nvim_set_current_win(current_win) + -- If the winid is not provided, then line number should be 1, so that it can land on the first line + if not vim.api.nvim_win_is_valid(winid) then return 1 end + + local line = 1 + vim.api.nvim_win_call(winid, function() line = fn.winline() end) + return line end