fix(#2819): experimental.actions.open_file.relative_path issue following change directory (#2820)

fix issue with the description of epheien in #2819

Co-authored-by: eph <eph@MacBook-Pro.local>
This commit is contained in:
Epheien 2024-07-07 13:53:04 +08:00 committed by GitHub
parent d1957d3472
commit 12a9a995a4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -319,6 +319,15 @@ local function open_in_new_window(filename, mode)
end end
end end
if (mode == "preview" or mode == "preview_no_picker") and view.View.float.enable then
-- ignore "WinLeave" autocmd on preview
-- because the registered "WinLeave"
-- will kill the floating window immediately
set_current_win_no_autocmd(target_winid, { "WinLeave", "BufEnter" })
else
set_current_win_no_autocmd(target_winid, { "BufEnter" })
end
local fname local fname
if M.relative_path then if M.relative_path then
fname = utils.escape_special_chars(vim.fn.fnameescape(utils.path_relative(filename, vim.fn.getcwd()))) fname = utils.escape_special_chars(vim.fn.fnameescape(utils.path_relative(filename, vim.fn.getcwd())))
@ -336,15 +345,6 @@ local function open_in_new_window(filename, mode)
command = { cmd = "edit", args = { fname } } command = { cmd = "edit", args = { fname } }
end end
if (mode == "preview" or mode == "preview_no_picker") and view.View.float.enable then
-- ignore "WinLeave" autocmd on preview
-- because the registered "WinLeave"
-- will kill the floating window immediately
set_current_win_no_autocmd(target_winid, { "WinLeave", "BufEnter" })
else
set_current_win_no_autocmd(target_winid, { "BufEnter" })
end
pcall(vim.api.nvim_cmd, command, { output = false }) pcall(vim.api.nvim_cmd, command, { output = false })
lib.set_target_win() lib.set_target_win()
end end