feat: move a file to a new directory with its existing name, closes #35
parent
7ba13fa62d
commit
e221036576
|
|
@ -70,9 +70,9 @@ keymap("x", "<leader>x", genghis.moveSelectionToNewFile)
|
||||||
and moves the current selection to that new file. (Note that this is a Visual
|
and moves the current selection to that new file. (Note that this is a Visual
|
||||||
Line Mode command; the selection is moved linewise.)
|
Line Mode command; the selection is moved linewise.)
|
||||||
- `.renameFile` or `:Rename`: Rename the current file.
|
- `.renameFile` or `:Rename`: Rename the current file.
|
||||||
- `.moveAndRenameFile` or `:Move`: Move and Rename the current file. Works like
|
- `.moveAndRenameFile` or `:Move`: Move and Rename the current file. Keeps the
|
||||||
the UNIX `mv` command. Best used with [autocompletion of
|
old name if the new path ends with `/`. Works like the UNIX `mv` command. Best
|
||||||
directories](#autocompletion-of-directories).
|
used with [autocompletion of directories](#autocompletion-of-directories).
|
||||||
|
|
||||||
The following applies to all commands above:
|
The following applies to all commands above:
|
||||||
- If no extension has been provided, uses the extension of the original file.
|
- If no extension has been provided, uses the extension of the original file.
|
||||||
|
|
|
||||||
|
|
@ -130,9 +130,12 @@ local function fileOp(op)
|
||||||
-- VALIDATION OF FILENAME
|
-- VALIDATION OF FILENAME
|
||||||
if not newName then return end -- input has been canceled
|
if not newName then return end -- input has been canceled
|
||||||
|
|
||||||
|
if newName:find("/$") then
|
||||||
|
newName = newName .. oldName -- use the new directory with the old name
|
||||||
|
end
|
||||||
|
|
||||||
local invalidName = newName:find("^%s+$")
|
local invalidName = newName:find("^%s+$")
|
||||||
or newName:find("[\\:]")
|
or newName:find("[\\:]")
|
||||||
or newName:find("/$")
|
|
||||||
or (newName:find("^/") and not op == "move-rename")
|
or (newName:find("^/") and not op == "move-rename")
|
||||||
local sameName = newName == oldName
|
local sameName = newName == oldName
|
||||||
local emptyInput = newName == ""
|
local emptyInput = newName == ""
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue