mirror of
https://github.com/tpope/vim-fugitive.git
synced 2025-11-08 11:33:47 -05:00
Tease apart :Gedit argument parsing and expansion
This commit is contained in:
@@ -2025,6 +2025,8 @@ function! s:Expand(rev, ...) abort
|
|||||||
let file = len(expand('%')) ? a:rev[-2:-1] . ':%' : '%'
|
let file = len(expand('%')) ? a:rev[-2:-1] . ':%' : '%'
|
||||||
elseif a:rev =~# '^>\%(:\=/\)\=$'
|
elseif a:rev =~# '^>\%(:\=/\)\=$'
|
||||||
let file = '%'
|
let file = '%'
|
||||||
|
elseif a:rev =~# '^>[> ]\@!' && @% !~# '^fugitive:' && s:Slash(@%) =~# '://'
|
||||||
|
let file = '%'
|
||||||
elseif a:rev ==# '>:'
|
elseif a:rev ==# '>:'
|
||||||
let file = empty(s:DirCommitFile(@%)[0]) ? ':0:%' : '%'
|
let file = empty(s:DirCommitFile(@%)[0]) ? ':0:%' : '%'
|
||||||
elseif a:rev =~# '^>[> ]\@!'
|
elseif a:rev =~# '^>[> ]\@!'
|
||||||
@@ -5990,28 +5992,37 @@ function! s:OpenParse(string, wants_cmd) abort
|
|||||||
break
|
break
|
||||||
endif
|
endif
|
||||||
endwhile
|
endwhile
|
||||||
if len(args) && args !=# ['>:']
|
if empty(args) && !empty(@%)
|
||||||
let file = join(args)
|
let args = ['>:']
|
||||||
if file ==# '-'
|
endif
|
||||||
|
let dir = s:Dir()
|
||||||
|
let [url, lnum] = s:OpenExpand(dir, join(args), a:wants_cmd)
|
||||||
|
if lnum
|
||||||
|
call insert(cmds, lnum)
|
||||||
|
endif
|
||||||
|
|
||||||
|
let pre = join(opts, '')
|
||||||
|
if len(cmds) > 1
|
||||||
|
let pre .= ' +' . s:PlusEscape(join(map(cmds, '"exe ".string(v:val)'), '|'))
|
||||||
|
elseif len(cmds)
|
||||||
|
let pre .= ' +' . s:PlusEscape(cmds[0])
|
||||||
|
endif
|
||||||
|
return [url, pre]
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! s:OpenExpand(dir, file, wants_cmd) abort
|
||||||
|
if a:file ==# '-'
|
||||||
let result = fugitive#Result()
|
let result = fugitive#Result()
|
||||||
if has_key(result, 'file')
|
if has_key(result, 'file')
|
||||||
let file = s:fnameescape(result.file)
|
let efile = result.file
|
||||||
else
|
else
|
||||||
throw 'fugitive: no previous command output'
|
throw 'fugitive: no previous command output'
|
||||||
endif
|
endif
|
||||||
endif
|
|
||||||
elseif empty(expand('%'))
|
|
||||||
let file = ''
|
|
||||||
elseif empty(s:DirCommitFile(@%)[1]) && s:Relative('./') !~# '^\./\.git\>'
|
|
||||||
let file = '>:0'
|
|
||||||
else
|
else
|
||||||
let file = '>'
|
let efile = s:Expand(a:file)
|
||||||
endif
|
endif
|
||||||
let dir = s:Dir()
|
let url = s:Generate(efile, a:dir)
|
||||||
let efile = s:Expand(file)
|
if a:wants_cmd && a:file[0] ==# '>' && efile[0] !=# '>' && get(b:, 'fugitive_type', '') isnot# 'tree' && &filetype !=# 'netrw'
|
||||||
let url = s:Generate(efile, dir)
|
|
||||||
|
|
||||||
if a:wants_cmd && file[0] ==# '>' && efile[0] !=# '>' && get(b:, 'fugitive_type', '') isnot# 'tree' && &filetype !=# 'netrw'
|
|
||||||
let line = line('.')
|
let line = line('.')
|
||||||
if expand('%:p') !=# url
|
if expand('%:p') !=# url
|
||||||
let diffcmd = 'diff'
|
let diffcmd = 'diff'
|
||||||
@@ -6028,7 +6039,7 @@ function! s:OpenParse(string, wants_cmd) abort
|
|||||||
else
|
else
|
||||||
let args = [from, to]
|
let args = [from, to]
|
||||||
endif
|
endif
|
||||||
let [res, exec_error] = s:LinesError([dir, diffcmd, '-U0'] + args)
|
let [res, exec_error] = s:LinesError([a:dir, diffcmd, '-U0'] + args)
|
||||||
if !exec_error
|
if !exec_error
|
||||||
call filter(res, 'v:val =~# "^@@ "')
|
call filter(res, 'v:val =~# "^@@ "')
|
||||||
call map(res, 'substitute(v:val, ''[-+]\d\+\zs '', ",1 ", "g")')
|
call map(res, 'substitute(v:val, ''[-+]\d\+\zs '', ",1 ", "g")')
|
||||||
@@ -6045,16 +6056,9 @@ function! s:OpenParse(string, wants_cmd) abort
|
|||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
call insert(cmds, line)
|
return [url, line]
|
||||||
endif
|
endif
|
||||||
|
return [url, 0]
|
||||||
let pre = join(opts, '')
|
|
||||||
if len(cmds) > 1
|
|
||||||
let pre .= ' +' . s:PlusEscape(join(map(cmds, '"exe ".string(v:val)'), '|'))
|
|
||||||
elseif len(cmds)
|
|
||||||
let pre .= ' +' . s:PlusEscape(cmds[0])
|
|
||||||
endif
|
|
||||||
return [url, pre]
|
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! fugitive#DiffClose() abort
|
function! fugitive#DiffClose() abort
|
||||||
|
|||||||
Reference in New Issue
Block a user