feat: trash support for linux and mac (#165)
* wip: skeleton code for trash adapter * refactor: split trash implementation for mac and linux * fix: ensure we create the .Trash/$uid dir * feat: code complete linux trash implementation * doc: write up trash features * feat: code complete mac trash implementation * cleanup: remove previous, terrible, undocumented trash feature * fix: always disabled trash * feat: show original path of trashed files * doc: add a note about calling actions directly * fix: bugs in trash implementation * fix: schedule_wrap in mac trash * doc: fix typo and line wrapping * fix: parsing of arguments to :Oil command * doc: small documentation tweaks * doc: fix awkward wording in the toggle_trash action * fix: warning on Windows when delete_to_trash = true * feat: :Oil --trash can open specific trash directories * fix: show all trash files in device root * fix: trash mtime should be sortable * fix: shorten_path handles optional trailing slash * refactor: overhaul the UI * fix: keep trash original path vtext from stacking * refactor: replace disable_changes with an error filter * fix: shorten path names in home directory relative to root * doc: small README format changes * cleanup: remove unnecessary preserve_undo logic * test: add a functional test for the freedesktop trash adapter * test: more functional tests for trash * fix: schedule a callback to avoid main loop error * refactor: clean up mutator logic * doc: some comments and type annotations
This commit is contained in:
parent
d8f0d91b10
commit
6175bd6462
27 changed files with 1580 additions and 229 deletions
|
|
@ -1,16 +1,7 @@
|
|||
local fs = require("oil.fs")
|
||||
local test_util = require("tests.test_util")
|
||||
|
||||
local function throwiferr(err, ...)
|
||||
if err then
|
||||
error(err)
|
||||
else
|
||||
return ...
|
||||
end
|
||||
end
|
||||
|
||||
local function await(fn, nargs, ...)
|
||||
return throwiferr(a.wrap(fn, nargs)(...))
|
||||
end
|
||||
local await = test_util.await
|
||||
|
||||
---@param path string
|
||||
---@param cb fun(err: nil|string)
|
||||
|
|
@ -41,6 +32,7 @@ local TmpDir = {}
|
|||
|
||||
TmpDir.new = function()
|
||||
local path = await(vim.loop.fs_mkdtemp, 2, "oil_test_XXXXXXXXX")
|
||||
a.util.scheduler()
|
||||
return setmetatable({ path = path }, {
|
||||
__index = TmpDir,
|
||||
})
|
||||
|
|
@ -60,6 +52,7 @@ function TmpDir:create(paths)
|
|||
end
|
||||
end
|
||||
end
|
||||
a.util.scheduler()
|
||||
end
|
||||
|
||||
---@param filepath string
|
||||
|
|
@ -72,6 +65,7 @@ local read_file = function(filepath)
|
|||
local stat = vim.loop.fs_fstat(fd)
|
||||
local content = vim.loop.fs_read(fd, stat.size)
|
||||
vim.loop.fs_close(fd)
|
||||
a.util.scheduler()
|
||||
return content
|
||||
end
|
||||
|
||||
|
|
@ -99,9 +93,9 @@ local assert_fs = function(root, paths)
|
|||
local pieces = vim.split(k, "/")
|
||||
local partial_path = ""
|
||||
for i, piece in ipairs(pieces) do
|
||||
partial_path = fs.join(partial_path, piece) .. "/"
|
||||
partial_path = partial_path .. piece .. "/"
|
||||
if i ~= #pieces then
|
||||
unlisted_dirs[partial_path:sub(2)] = true
|
||||
unlisted_dirs[partial_path] = true
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -152,8 +146,23 @@ function TmpDir:assert_fs(paths)
|
|||
assert_fs(self.path, paths)
|
||||
end
|
||||
|
||||
function TmpDir:assert_exists(path)
|
||||
a.util.scheduler()
|
||||
path = fs.join(self.path, path)
|
||||
local stat = vim.loop.fs_stat(path)
|
||||
assert.truthy(stat, string.format("Expected path '%s' to exist", path))
|
||||
end
|
||||
|
||||
function TmpDir:assert_not_exists(path)
|
||||
a.util.scheduler()
|
||||
path = fs.join(self.path, path)
|
||||
local stat = vim.loop.fs_stat(path)
|
||||
assert.falsy(stat, string.format("Expected path '%s' to not exist", path))
|
||||
end
|
||||
|
||||
function TmpDir:dispose()
|
||||
await(fs.recursive_delete, 3, "directory", self.path)
|
||||
a.util.scheduler()
|
||||
end
|
||||
|
||||
return TmpDir
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue