Special case :0Gread to get around FileReadCmd limitations

This commit is contained in:
Tim Pope 2018-08-20 01:11:29 -04:00
parent 67e9756c35
commit bb2797d313

View File

@ -2233,7 +2233,7 @@ function! s:EditParse(args) abort
let pre = [] let pre = []
let args = copy(a:args) let args = copy(a:args)
while !empty(args) && args[0] =~# '^+' while !empty(args) && args[0] =~# '^+'
call add(pre, escape(remove(args, 0), ' |"') . ' ') call add(pre, ' ' . escape(remove(args, 0), ' |"'))
endwhile endwhile
if len(args) if len(args)
let file = join(args) let file = join(args)
@ -2312,7 +2312,7 @@ function! s:Edit(cmd, bang, mods, args, ...) abort
if a:cmd ==# 'edit' if a:cmd ==# 'edit'
call s:BlurStatus() call s:BlurStatus()
endif endif
return mods . ' ' . a:cmd . ' ' . pre . s:fnameescape(file) return mods . ' ' . a:cmd . pre . ' ' . s:fnameescape(file)
endfunction endfunction
function! s:Read(count, line1, line2, range, bang, mods, args, ...) abort function! s:Read(count, line1, line2, range, bang, mods, args, ...) abort
@ -2347,7 +2347,10 @@ function! s:Read(count, line1, line2, range, bang, mods, args, ...) abort
catch /^fugitive:/ catch /^fugitive:/
return 'echoerr v:errmsg' return 'echoerr v:errmsg'
endtry endtry
return mods . ' ' . after . 'read ' . pre . s:fnameescape(file) . '|' . delete . 'diffupdate' . (a:count < 0 ? '|' . line('.') : '') if file =~# '^fugitive:' && after is# 0
return 'exe ' .string(mods . ' ' . fugitive#FileReadCmd(file, 0, pre)) . '|diffupdate'
endif
return mods . ' ' . after . 'read' . pre . ' ' . s:fnameescape(file) . '|' . delete . 'diffupdate' . (a:count < 0 ? '|' . line('.') : '')
endfunction endfunction
function! s:EditRunComplete(A,L,P) abort function! s:EditRunComplete(A,L,P) abort