mirror of
https://github.com/tpope/vim-fugitive.git
synced 2025-11-11 12:53:52 -05:00
Expand :GMove and :GRename arguments
This commit is contained in:
@@ -6345,34 +6345,45 @@ function! s:Move(force, rename, destination) abort
|
|||||||
if s:DirCommitFile(@%)[1] !~# '^0\=$' || empty(@%)
|
if s:DirCommitFile(@%)[1] !~# '^0\=$' || empty(@%)
|
||||||
return 'echoerr ' . string('fugitive: mv not supported for this buffer')
|
return 'echoerr ' . string('fugitive: mv not supported for this buffer')
|
||||||
endif
|
endif
|
||||||
if a:destination =~# '^\a\+:\|^/'
|
if a:rename
|
||||||
let destination = a:destination
|
let default_root = expand('%:p:s?[\/]$??:h') . '/'
|
||||||
elseif a:destination =~# '^:/:\='
|
|
||||||
let destination = s:Tree(dir) . substitute(a:destination, '^:/:\=', '', '')
|
|
||||||
elseif a:destination =~# '^:(\%(top\|top,literal\|literal,top\))'
|
|
||||||
let destination = s:Tree(dir) . matchstr(a:destination, ')\zs.*')
|
|
||||||
elseif a:destination =~# '^:(literal)'
|
|
||||||
let destination = simplify(getcwd() . '/' . matchstr(a:destination, ')\zs.*'))
|
|
||||||
elseif a:rename
|
|
||||||
let destination = simplify(expand('%:p:s?[\/]$??:h') . '/' . a:destination)
|
|
||||||
elseif a:destination =~# '^\.\.\=\%(/\|$\)'
|
|
||||||
let destination = simplify(getcwd() . '/' . a:destination)
|
|
||||||
else
|
else
|
||||||
let destination = s:Tree(dir) . '/' . a:destination
|
let default_root = s:Tree(dir) . '/'
|
||||||
|
endif
|
||||||
|
if a:destination =~# '^:/:\='
|
||||||
|
let destination = s:Tree(dir) . s:Expand(substitute(a:destination, '^:/:\=', '', ''))
|
||||||
|
elseif a:destination =~# '^:(top)'
|
||||||
|
let destination = s:Expand(matchstr(a:destination, ')\zs.*'))
|
||||||
|
if destination !~# '^/\|^\a\+:'
|
||||||
|
let destination = s:Tree(dir) . '/' . destination
|
||||||
|
endif
|
||||||
|
let destination = s:Tree(dir) .
|
||||||
|
elseif a:destination =~# '^:(\%(top,literal\|literal,top\))'
|
||||||
|
let destination = s:Tree(dir) . matchstr(a:destination, ')\zs.*')
|
||||||
|
elseif a:destination =~# '^:(literal)\.\.\=\%(/\|$\)'
|
||||||
|
let destination = simplify(getcwd() . '/' . matchstr(a:destination, ')\zs.*'))
|
||||||
|
elseif a:destination =~# '^:(literal)'
|
||||||
|
let destination = simplify(default_root . matchstr(a:destination, ')\zs.*'))
|
||||||
|
else
|
||||||
|
let destination = s:Expand(a:destination)
|
||||||
|
if destination =~# '^\.\.\=\%(/\|$\)'
|
||||||
|
let destination = simplify(getcwd() . '/' . destination)
|
||||||
|
elseif destination !~# '^\a\+:\|^/'
|
||||||
|
let destination = default_root . destination
|
||||||
|
endif
|
||||||
endif
|
endif
|
||||||
let destination = s:Slash(destination)
|
let destination = s:Slash(destination)
|
||||||
if isdirectory(@%)
|
if isdirectory(@%)
|
||||||
setlocal noswapfile
|
setlocal noswapfile
|
||||||
endif
|
endif
|
||||||
let message = s:ChompStderr(['mv'] + (a:force ? ['-f'] : []) + ['--', expand('%:p'), destination], dir)
|
let exec = fugitive#Execute(['mv'] + (a:force ? ['-f'] : []) + ['--', expand('%:p'), destination], dir)
|
||||||
if len(message)
|
if exec.exit_status && exec.stderr !=# ['']
|
||||||
let v:errmsg = 'fugitive: '.message
|
return 'echoerr ' .string('fugitive: '.s:JoinChomp(exec.stderr))
|
||||||
return 'echoerr v:errmsg'
|
|
||||||
endif
|
endif
|
||||||
if isdirectory(destination)
|
if isdirectory(destination)
|
||||||
let destination = fnamemodify(s:sub(destination,'/$','').'/'.expand('%:t'),':.')
|
let destination = fnamemodify(s:sub(destination,'/$','').'/'.expand('%:t'),':.')
|
||||||
endif
|
endif
|
||||||
let reload = '|call fugitive#DidChange(' . string(dir) . ')'
|
let reload = '|call fugitive#DidChange(' . string(exec) . ')'
|
||||||
if empty(s:DirCommitFile(@%)[1])
|
if empty(s:DirCommitFile(@%)[1])
|
||||||
if isdirectory(destination)
|
if isdirectory(destination)
|
||||||
return 'keepalt edit '.s:fnameescape(destination) . reload
|
return 'keepalt edit '.s:fnameescape(destination) . reload
|
||||||
|
|||||||
Reference in New Issue
Block a user