From 03d8c35bf7b0541a877348cefc486dcd02142ec7 Mon Sep 17 00:00:00 2001 From: bhagwan Date: Mon, 13 Nov 2023 12:06:05 -0800 Subject: [PATCH] fix(lsp): clear context on `jump_to_single_result` (closes #928) --- lua/fzf-lua/utils.lua | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lua/fzf-lua/utils.lua b/lua/fzf-lua/utils.lua index 0a56b4e4..8c2548bc 100644 --- a/lua/fzf-lua/utils.lua +++ b/lua/fzf-lua/utils.lua @@ -550,7 +550,14 @@ function M.get_visual_selection() end function M.fzf_exit() - vim.cmd([[lua require('fzf-lua.win').win_leave()]]) + -- Usually called from the LSP module to exit the interface on "async" mode + -- when no results are found or when `jump_to_single_result` is used, when + -- the latter is used in "sync" mode we also need to make sure core.__CTX + -- is cleared or we'll have the wrong cursor coordiantes (#928) + return loadstring([[ + require('fzf-lua').core.__CTX = nil + require('fzf-lua').win.win_leave() + ]])() end function M.fzf_winobj()