fix root inside win open

This commit is contained in:
sheffey 2025-05-30 16:37:36 +08:00
parent 8ca577b4b5
commit 3f8cf3e812
2 changed files with 3 additions and 2 deletions

View file

@ -173,7 +173,7 @@ function M.get(cmd, opts)
opts = opts or {}
local id = vim.inspect({ cmd = cmd, cwd = opts.cwd, env = opts.env, count = vim.v.count1 })
local created = false
if not (terminals[id] and terminals[id]:win_valid() and terminals[id]:buf_valid()) and (opts.create ~= false) then
if not (terminals[id] and terminals[id]:buf_valid()) and (opts.create ~= false) then
local ret = M.open(cmd, opts)
ret:on("BufWipeout", function()
terminals[id] = nil

View file

@ -701,7 +701,7 @@ function M:open_win()
elseif position == "current" then
self.win = vim.api.nvim_get_current_win()
else
local parent = self.opts.win or 0
local parent = self:win_valid() and self.opts.win or 0
local vertical = position == "left" or position == "right"
if parent == 0 then
for _, win in ipairs(vim.api.nvim_tabpage_list_wins(0)) do
@ -717,6 +717,7 @@ function M:open_win()
break
end
end
self.opts.win = parent
end
local cmd = split_commands[relative][position]
local size = vertical and opts.width or opts.height