mirror of
https://github.com/folke/snacks.nvim
synced 2025-08-05 03:08:13 +00:00
fix(explorer): check that picker is still open
This commit is contained in:
parent
a6bb63fa09
commit
50fa1be38e
1 changed files with 9 additions and 6 deletions
|
@ -34,7 +34,11 @@ function State.new(picker)
|
||||||
local self = setmetatable({}, State)
|
local self = setmetatable({}, State)
|
||||||
|
|
||||||
local opts = picker.opts --[[@as snacks.picker.explorer.Config]]
|
local opts = picker.opts --[[@as snacks.picker.explorer.Config]]
|
||||||
local ref = picker:ref()
|
local r = picker:ref()
|
||||||
|
local function ref()
|
||||||
|
local v = r.value
|
||||||
|
return v and not v.closed and v or nil
|
||||||
|
end
|
||||||
|
|
||||||
local buf = vim.api.nvim_win_get_buf(picker.main)
|
local buf = vim.api.nvim_win_get_buf(picker.main)
|
||||||
local buf_file = vim.fs.normalize(vim.api.nvim_buf_get_name(buf))
|
local buf_file = vim.fs.normalize(vim.api.nvim_buf_get_name(buf))
|
||||||
|
@ -58,11 +62,10 @@ function State.new(picker)
|
||||||
|
|
||||||
picker.list.win:on("BufWritePost", function(_, ev)
|
picker.list.win:on("BufWritePost", function(_, ev)
|
||||||
local p = ref()
|
local p = ref()
|
||||||
if not p then
|
if p then
|
||||||
return true
|
|
||||||
end
|
|
||||||
Tree:refresh(ev.file)
|
Tree:refresh(ev.file)
|
||||||
Actions.update(p)
|
Actions.update(p)
|
||||||
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
picker.list.win:on("DirChanged", function(_, ev)
|
picker.list.win:on("DirChanged", function(_, ev)
|
||||||
|
@ -81,7 +84,7 @@ function State.new(picker)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
local p = ref()
|
local p = ref()
|
||||||
if not p or p:is_focused() or not p:on_current_tab() then
|
if not p or p:is_focused() or not p:on_current_tab() or p.closed then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
local win = vim.api.nvim_get_current_win()
|
local win = vim.api.nvim_get_current_win()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue