feat: a link brings a hidden lazysecrets back, unless nvim is busy
state(pid) and reveal(pid), for lazysecrets to call through $NVIM when a link is handed to it: the hidden window comes back when nvim is in normal or terminal mode; while you're typing, in a command or a picker, or mid-operator, the link opens elsewhere.
This commit is contained in:
3 files changed
+57
No files matched your search
@@ -42,5 +42,26 @@ vim.cmd.wincmd("p")
|
||||
m.open({ cwd = other .. "/sub" })
|
||||
assert(job() ~= first, "opening in another repo reused the first one")
|
||||
|
||||
-- state and reveal, as lazysecrets asks them from outside for a link.
|
||||
local pid = vim.fn.jobpid(job())
|
||||
assert(m.state(pid) == "shown", "state of the open window: " .. m.state(pid))
|
||||
assert(m.state(pid + 1) == "none", "state of another process")
|
||||
vim.cmd.wincmd("p")
|
||||
vim.wait(100, function()
|
||||
return m.state(pid) == "hidden"
|
||||
end)
|
||||
assert(m.state(pid) == "hidden", "leaving the window didn't hide it: " .. m.state(pid))
|
||||
|
||||
local get_mode = vim.api.nvim_get_mode
|
||||
vim.api.nvim_get_mode = function()
|
||||
return { mode = "c", blocking = false } -- typing a command
|
||||
end
|
||||
assert(m.state(pid) == "busy" and not m.reveal(pid), "a link would interrupt a command")
|
||||
assert(vim.api.nvim_win_get_config(0).relative == "", "reveal() showed the window while busy")
|
||||
vim.api.nvim_get_mode = get_mode
|
||||
|
||||
assert(m.reveal(pid), "reveal() of the hidden window")
|
||||
assert(vim.api.nvim_win_get_config(0).relative == "editor" and vim.fn.jobpid(job()) == pid, "reveal() didn't bring the window back")
|
||||
|
||||
vim.fn.delete(tmp, "rf")
|
||||
print("ok")
|
||||
Reference in new issue
Block a user