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()
|
||||
local util = require("oil.util")
|
||||
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
|
||||
view.maybe_set_cursor()
|
||||
else
|
||||
-- Only run this logic if we are *not* in an oil buffer.
|
||||
elseif vim.fn.isdirectory(bufname) == 0 then
|
||||
-- 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
|
||||
restore_alt_buf()
|
||||
end
|
||||
|
|
|
|||
|
|
@ -127,12 +127,14 @@ M.rename_buffer = function(src_bufnr, dest_buf_name)
|
|||
end
|
||||
end
|
||||
end
|
||||
if vim.bo[src_bufnr].modified then
|
||||
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)
|
||||
if vim.api.nvim_buf_is_valid(src_bufnr) then
|
||||
if vim.bo[src_bufnr].modified then
|
||||
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)
|
||||
end
|
||||
-- Try to delete, but don't if the buffer has changes
|
||||
pcall(vim.api.nvim_buf_delete, src_bufnr, {})
|
||||
end
|
||||
-- Try to delete, but don't if the buffer has changes
|
||||
pcall(vim.api.nvim_buf_delete, src_bufnr, {})
|
||||
end)
|
||||
return true
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue