* fix: preview on floating window * chore: redrawing the tree after setting current win * chore: ignore winleave autocmd on preview action * fix: typo in comment * chore: call correct window id * chore: revert changes in focus method * chore: check if float window is enabled before ignoring WinLeave
This commit is contained in:
@@ -167,9 +167,9 @@ end
|
|||||||
|
|
||||||
-- This is only to avoid the BufEnter for nvim-tree to trigger
|
-- This is only to avoid the BufEnter for nvim-tree to trigger
|
||||||
-- which would cause find-file to run on an invalid file.
|
-- which would cause find-file to run on an invalid file.
|
||||||
local function set_current_win_no_autocmd(winid)
|
local function set_current_win_no_autocmd(winid, autocmd)
|
||||||
local eventignore = vim.opt.eventignore:get()
|
local eventignore = vim.opt.eventignore:get()
|
||||||
vim.opt.eventignore:append "BufEnter"
|
vim.opt.eventignore:append(autocmd)
|
||||||
api.nvim_set_current_win(winid)
|
api.nvim_set_current_win(winid)
|
||||||
vim.opt.eventignore = eventignore
|
vim.opt.eventignore = eventignore
|
||||||
end
|
end
|
||||||
@@ -211,7 +211,15 @@ local function open_in_new_window(filename, mode, win_ids)
|
|||||||
cmd = string.format("edit %s", fname)
|
cmd = string.format("edit %s", fname)
|
||||||
end
|
end
|
||||||
|
|
||||||
set_current_win_no_autocmd(target_winid)
|
if mode == "preview" 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.cmd, cmd)
|
pcall(vim.cmd, cmd)
|
||||||
lib.set_target_win()
|
lib.set_target_win()
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user