fix: warning when :tabnew from oil buffer (#40)

This commit is contained in:
Steven Arcangeli 2023-01-18 23:16:27 -08:00
parent ca4da68aae
commit 73c6fcf519
2 changed files with 20 additions and 1 deletions

View file

@ -705,7 +705,9 @@ M.setup = function(opts)
-- This new window is a split off of an oil window. We need to transfer the window
-- variables. First, locate the parent window
local parent_win
for _, winid in ipairs(vim.api.nvim_tabpage_list_wins(0)) do
-- First search windows in this tab, then search all windows
local winids = vim.list_extend(vim.api.nvim_tabpage_list_wins(0), vim.api.nvim_list_wins())
for _, winid in ipairs(winids) do
if vim.api.nvim_win_is_valid(winid) then
if vim.w[winid].oil_did_enter then
parent_win = winid

View file

@ -40,4 +40,21 @@ a.describe("window options", function()
vim.cmd.edit({ args = { "README.md" } })
assert.equals("auto", vim.o.signcolumn)
end)
a.it("Restores window options on tabnew <filename>", function()
oil.open()
test_util.wait_for_autocmd("BufReadPost")
assert.equals("no", vim.o.signcolumn)
vim.cmd.tabnew({ args = { "README.md" } })
assert.equals("auto", vim.o.signcolumn)
end)
a.it("Restores window options on tabnew", function()
oil.open()
test_util.wait_for_autocmd("BufReadPost")
assert.equals("no", vim.o.signcolumn)
vim.cmd.tabnew()
vim.cmd.edit({ args = { "README.md" } })
assert.equals("auto", vim.o.signcolumn)
end)
end)