fix: error when editing a dir, and still missing parent window (#40)
This commit is contained in:
parent
f5961e731f
commit
a6884431b0
2 changed files with 12 additions and 8 deletions
|
|
@ -673,11 +673,13 @@ M.setup = function(opts)
|
||||||
callback = function()
|
callback = function()
|
||||||
local util = require("oil.util")
|
local util = require("oil.util")
|
||||||
local view = require("oil.view")
|
local view = require("oil.view")
|
||||||
local scheme = util.parse_url(vim.api.nvim_buf_get_name(0))
|
local bufname = vim.api.nvim_buf_get_name(0)
|
||||||
|
local scheme = util.parse_url(bufname)
|
||||||
if scheme and config.adapters[scheme] then
|
if scheme and config.adapters[scheme] then
|
||||||
view.maybe_set_cursor()
|
view.maybe_set_cursor()
|
||||||
else
|
elseif vim.fn.isdirectory(bufname) == 0 then
|
||||||
-- Only run this logic if we are *not* in an oil buffer.
|
-- Only run this logic if we are *not* in an oil buffer (and it's not a directory, which
|
||||||
|
-- will be replaced by an oil:// url)
|
||||||
-- Oil buffers have to run it in BufReadCmd after confirming they are a directory or a file
|
-- Oil buffers have to run it in BufReadCmd after confirming they are a directory or a file
|
||||||
restore_alt_buf()
|
restore_alt_buf()
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -127,12 +127,14 @@ M.rename_buffer = function(src_bufnr, dest_buf_name)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
if vim.api.nvim_buf_is_valid(src_bufnr) then
|
||||||
if vim.bo[src_bufnr].modified then
|
if vim.bo[src_bufnr].modified then
|
||||||
local src_lines = vim.api.nvim_buf_get_lines(src_bufnr, 0, -1, true)
|
local src_lines = vim.api.nvim_buf_get_lines(src_bufnr, 0, -1, true)
|
||||||
vim.api.nvim_buf_set_lines(dest_bufnr, 0, -1, true, src_lines)
|
vim.api.nvim_buf_set_lines(dest_bufnr, 0, -1, true, src_lines)
|
||||||
end
|
end
|
||||||
-- Try to delete, but don't if the buffer has changes
|
-- Try to delete, but don't if the buffer has changes
|
||||||
pcall(vim.api.nvim_buf_delete, src_bufnr, {})
|
pcall(vim.api.nvim_buf_delete, src_bufnr, {})
|
||||||
|
end
|
||||||
end)
|
end)
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue