refactor: rename supports_xfer
This commit is contained in:
parent
f4819d8b43
commit
7aeb239a6a
4 changed files with 13 additions and 7 deletions
|
|
@ -352,7 +352,7 @@ M.render_action = function(action)
|
|||
M.to_short_os_path(dest_path, action.entry_type)
|
||||
)
|
||||
else
|
||||
-- We should never hit this because we don't implement supports_xfer
|
||||
-- We should never hit this because we don't implement supported_adapters_for_copy
|
||||
error("files adapter doesn't support cross-adapter move/copy")
|
||||
end
|
||||
else
|
||||
|
|
@ -409,7 +409,7 @@ M.perform_action = function(action, cb)
|
|||
dest_path = fs.posix_to_os_path(dest_path)
|
||||
fs.recursive_move(action.entry_type, src_path, dest_path, vim.schedule_wrap(cb))
|
||||
else
|
||||
-- We should never hit this because we don't implement supports_xfer
|
||||
-- We should never hit this because we don't implement supported_adapters_for_copy
|
||||
cb("files adapter doesn't support cross-adapter move")
|
||||
end
|
||||
elseif action.type == "copy" then
|
||||
|
|
@ -423,7 +423,7 @@ M.perform_action = function(action, cb)
|
|||
dest_path = fs.posix_to_os_path(dest_path)
|
||||
fs.recursive_copy(action.entry_type, src_path, dest_path, cb)
|
||||
else
|
||||
-- We should never hit this because we don't implement supports_xfer
|
||||
-- We should never hit this because we don't implement supported_adapters_for_copy
|
||||
cb("files adapter doesn't support cross-adapter copy")
|
||||
end
|
||||
else
|
||||
|
|
|
|||
|
|
@ -338,7 +338,7 @@ M.perform_action = function(action, cb)
|
|||
end
|
||||
end
|
||||
|
||||
M.supports_xfer = { files = true }
|
||||
M.supported_adapters_for_copy = { files = true }
|
||||
|
||||
---@param bufnr integer
|
||||
M.read_file = function(bufnr)
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ local M = {}
|
|||
---@field perform_action? fun(action: oil.Action, cb: fun(err: nil|string)) Perform a mutation action. Only needed if adapter is modifiable.
|
||||
---@field read_file? fun(bufnr: integer) Used for adapters that deal with remote/virtual files. Read the contents of the file into a buffer.
|
||||
---@field write_file? fun(bufnr: integer) Used for adapters that deal with remote/virtual files. Write the contents of a buffer to the destination.
|
||||
---@field supports_xfer? table<string, boolean> This and all other parts of cross-adapter actions are WIP and not a stable API.
|
||||
---@field supported_adapters_for_copy? table<string, boolean> Mapping of adapter name to true for all other adapters that can be used as a src or dest for move/copy actions.
|
||||
|
||||
-- TODO remove after https://github.com/folke/neodev.nvim/pull/163 lands
|
||||
---@diagnostic disable: undefined-field
|
||||
|
|
|
|||
|
|
@ -461,9 +461,15 @@ M.get_adapter_for_action = function(action)
|
|||
if action.dest_url then
|
||||
local dest_adapter = assert(config.get_adapter_by_scheme(action.dest_url))
|
||||
if adapter ~= dest_adapter then
|
||||
if adapter.supports_xfer and adapter.supports_xfer[dest_adapter.name] then
|
||||
if
|
||||
adapter.supported_adapters_for_copy
|
||||
and adapter.supported_adapters_for_copy[dest_adapter.name]
|
||||
then
|
||||
return adapter
|
||||
elseif dest_adapter.supports_xfer and dest_adapter.supports_xfer[adapter.name] then
|
||||
elseif
|
||||
dest_adapter.supported_adapters_for_copy
|
||||
and dest_adapter.supported_adapters_for_copy[adapter.name]
|
||||
then
|
||||
return dest_adapter
|
||||
else
|
||||
error(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue