fix: symbolic link target parsing fails if it has a trailing slash (#131)
This commit is contained in:
parent
2a63f9224f
commit
9be36a6488
2 changed files with 51 additions and 1 deletions
|
|
@ -41,6 +41,19 @@ a.describe("mutator", function()
|
|||
assert.are.same({ { entry_type = "directory", name = "foo", type = "new" } }, diffs)
|
||||
end)
|
||||
|
||||
it("detects new links", function()
|
||||
vim.cmd.edit({ args = { "oil-test:///foo/" } })
|
||||
local bufnr = vim.api.nvim_get_current_buf()
|
||||
set_lines(bufnr, {
|
||||
"a.txt -> b.txt",
|
||||
})
|
||||
local diffs = parser.parse(bufnr)
|
||||
assert.are.same(
|
||||
{ { entry_type = "link", name = "a.txt", type = "new", link = "b.txt" } },
|
||||
diffs
|
||||
)
|
||||
end)
|
||||
|
||||
it("detects deleted files", function()
|
||||
local file = cache.create_and_store_entry("oil-test:///foo/", "a.txt", "file")
|
||||
vim.cmd.edit({ args = { "oil-test:///foo/" } })
|
||||
|
|
@ -63,6 +76,18 @@ a.describe("mutator", function()
|
|||
}, diffs)
|
||||
end)
|
||||
|
||||
it("detects deleted links", function()
|
||||
local file = cache.create_and_store_entry("oil-test:///foo/", "a.txt", "link")
|
||||
file[FIELD.meta] = { link = "b.txt" }
|
||||
vim.cmd.edit({ args = { "oil-test:///foo/" } })
|
||||
local bufnr = vim.api.nvim_get_current_buf()
|
||||
set_lines(bufnr, {})
|
||||
local diffs = parser.parse(bufnr)
|
||||
assert.are.same({
|
||||
{ name = "a.txt", type = "delete", id = file[FIELD.id] },
|
||||
}, diffs)
|
||||
end)
|
||||
|
||||
it("ignores empty lines", function()
|
||||
local file = cache.create_and_store_entry("oil-test:///foo/", "a.txt", "file")
|
||||
vim.cmd.edit({ args = { "oil-test:///foo/" } })
|
||||
|
|
@ -194,6 +219,18 @@ a.describe("mutator", function()
|
|||
{ name = "b.txt", type = "delete", id = bfile[FIELD.id] },
|
||||
}, last_two)
|
||||
end)
|
||||
|
||||
it("views link targets with trailing slashes as the same", function()
|
||||
local file = cache.create_and_store_entry("oil-test:///foo/", "mydir", "link")
|
||||
file[FIELD.meta] = { link = "dir/" }
|
||||
vim.cmd.edit({ args = { "oil-test:///foo/" } })
|
||||
local bufnr = vim.api.nvim_get_current_buf()
|
||||
set_lines(bufnr, {
|
||||
string.format("/%d mydir/ -> dir/", file[FIELD.id]),
|
||||
})
|
||||
local diffs = parser.parse(bufnr)
|
||||
assert.are.same({}, diffs)
|
||||
end)
|
||||
end)
|
||||
|
||||
describe("build actions", function()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue