fix: allow converting a file to directory and vice-versa (#117)

If you rename a file to have a `/` at the end, oil will detect the
change as a delete + new directory. Similarly, if you delete the
trailing `/` from a directory, it will delete the dir and create a new
file. This should help with the case where you want to create a new file
but forgot to add the trailing `/` and now you have a file instead.
This commit is contained in:
Steven Arcangeli 2023-09-09 18:33:43 -07:00
parent d4eb4f3bbf
commit 926ae067eb
2 changed files with 20 additions and 0 deletions

View file

@ -207,6 +207,12 @@ M.parse = function(bufnr)
entry_type = "link",
link = parsed_entry.link_target,
})
elseif entry[FIELD_TYPE] ~= parsed_entry._type then
table.insert(diffs, {
type = "new",
name = parsed_entry.name,
entry_type = parsed_entry._type,
})
else
original_entries[parsed_entry.name] = nil
end