mirror of
https://github.com/tpope/vim-fugitive.git
synced 2025-11-14 14:23:51 -05:00
Improve ++opt +cmd handling for :Gedit/:Gread
This commit is contained in:
@@ -3956,11 +3956,18 @@ function! s:UsableWin(nr) abort
|
|||||||
\ index(['nofile','help','quickfix'], getbufvar(winbufnr(a:nr), '&buftype')) < 0
|
\ index(['nofile','help','quickfix'], getbufvar(winbufnr(a:nr), '&buftype')) < 0
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:OpenParse(args) abort
|
function! s:OpenParse(args, wants_cmd) abort
|
||||||
let pre = []
|
let opts = []
|
||||||
|
let cmds = []
|
||||||
let args = copy(a:args)
|
let args = copy(a:args)
|
||||||
while !empty(args) && args[0] =~# '^+'
|
while !empty(args)
|
||||||
call add(pre, ' ' . escape(remove(args, 0), ' |"'))
|
if args[0] =~# '^++'
|
||||||
|
call add(opts, ' ' . escape(remove(args, 0), ' |"'))
|
||||||
|
elseif a:wants_cmd && args[0] =~# '^+'
|
||||||
|
call add(cmds, remove(args, 0)[1:-1])
|
||||||
|
else
|
||||||
|
break
|
||||||
|
endif
|
||||||
endwhile
|
endwhile
|
||||||
if len(args)
|
if len(args)
|
||||||
let file = join(args)
|
let file = join(args)
|
||||||
@@ -3971,7 +3978,13 @@ function! s:OpenParse(args) abort
|
|||||||
else
|
else
|
||||||
let file = '>'
|
let file = '>'
|
||||||
endif
|
endif
|
||||||
return [s:Expand(file), join(pre)]
|
let pre = join(opts, '')
|
||||||
|
if len(cmds) > 1
|
||||||
|
let pre .= ' +' . escape(join(map(cmds, '"exe ".string(v:val)'), '|'), ' |"')
|
||||||
|
elseif len(cmds)
|
||||||
|
let pre .= ' +' . escape(cmds[0], ' |"')
|
||||||
|
endif
|
||||||
|
return [s:Generate(s:Expand(file)), pre]
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:DiffClose() abort
|
function! s:DiffClose() abort
|
||||||
@@ -4039,8 +4052,7 @@ function! fugitive#Open(cmd, bang, mods, arg, args) abort
|
|||||||
|
|
||||||
let mods = s:Mods(a:mods)
|
let mods = s:Mods(a:mods)
|
||||||
try
|
try
|
||||||
let [file, pre] = s:OpenParse(a:args)
|
let [file, pre] = s:OpenParse(a:args, 1)
|
||||||
let file = s:Generate(file)
|
|
||||||
catch /^fugitive:/
|
catch /^fugitive:/
|
||||||
return 'echoerr ' . string(v:exception)
|
return 'echoerr ' . string(v:exception)
|
||||||
endtry
|
endtry
|
||||||
@@ -4073,8 +4085,7 @@ function! fugitive#ReadCommand(line1, count, range, bang, mods, arg, args) abort
|
|||||||
return 'redraw|echo '.string(':!'.s:UserCommand(dir, args))
|
return 'redraw|echo '.string(':!'.s:UserCommand(dir, args))
|
||||||
endif
|
endif
|
||||||
try
|
try
|
||||||
let [file, pre] = s:OpenParse(a:args)
|
let [file, pre] = s:OpenParse(a:args, 0)
|
||||||
let file = s:Generate(file)
|
|
||||||
catch /^fugitive:/
|
catch /^fugitive:/
|
||||||
return 'echoerr ' . string(v:exception)
|
return 'echoerr ' . string(v:exception)
|
||||||
endtry
|
endtry
|
||||||
|
|||||||
Reference in New Issue
Block a user