mirror of
https://github.com/tpope/vim-fugitive.git
synced 2025-11-11 12:53:52 -05:00
Support :Git ++curwin
The special case on :0Git is so weird that I am starting to think about an exit strategy.
This commit is contained in:
@@ -3319,7 +3319,8 @@ function! fugitive#Command(line1, line2, range, bang, mods, arg) abort
|
|||||||
exe s:DirCheck(dir)
|
exe s:DirCheck(dir)
|
||||||
endif
|
endif
|
||||||
let config = copy(fugitive#Config(dir))
|
let config = copy(fugitive#Config(dir))
|
||||||
let [args, after] = s:SplitExpandChain(a:arg, s:Tree(dir))
|
let curwin = a:arg =~# '^++curwin\>' || !a:line2
|
||||||
|
let [args, after] = s:SplitExpandChain(substitute(a:arg, '^++curwin\>\s*', '', ''), s:Tree(dir))
|
||||||
let flags = []
|
let flags = []
|
||||||
let pager = -1
|
let pager = -1
|
||||||
let explicit_pathspec_option = 0
|
let explicit_pathspec_option = 0
|
||||||
@@ -3369,7 +3370,7 @@ function! fugitive#Command(line1, line2, range, bang, mods, arg) abort
|
|||||||
endwhile
|
endwhile
|
||||||
let options = {'git': s:UserCommandList(), 'git_dir': s:GitDir(dir), 'flags': flags}
|
let options = {'git': s:UserCommandList(), 'git_dir': s:GitDir(dir), 'flags': flags}
|
||||||
if empty(args) && pager is# -1
|
if empty(args) && pager is# -1
|
||||||
let cmd = s:StatusCommand(a:line1, a:line2, a:range, a:line2, a:bang, a:mods, '', '', [], options)
|
let cmd = s:StatusCommand(a:line1, a:line2, a:range, curwin ? 0 : a:line2, a:bang, a:mods, '', '', [], options)
|
||||||
return (empty(cmd) ? 'exe' : cmd) . after
|
return (empty(cmd) ? 'exe' : cmd) . after
|
||||||
endif
|
endif
|
||||||
let alias = FugitiveConfigGet('alias.' . get(args, 0, ''), config)
|
let alias = FugitiveConfigGet('alias.' . get(args, 0, ''), config)
|
||||||
@@ -3381,7 +3382,7 @@ function! fugitive#Command(line1, line2, range, bang, mods, arg) abort
|
|||||||
let name = substitute(get(args, 0, ''), '\%(^\|-\)\(\l\)', '\u\1', 'g')
|
let name = substitute(get(args, 0, ''), '\%(^\|-\)\(\l\)', '\u\1', 'g')
|
||||||
if pager is# -1 && name =~# '^\a\+$' && exists('*s:' . name . 'Subcommand') && get(args, 1, '') !=# '--help'
|
if pager is# -1 && name =~# '^\a\+$' && exists('*s:' . name . 'Subcommand') && get(args, 1, '') !=# '--help'
|
||||||
try
|
try
|
||||||
let overrides = s:{name}Subcommand(a:line1, a:line2, a:range, a:bang, a:mods, extend({'subcommand': args[0], 'subcommand_args': args[1:-1]}, options))
|
let overrides = s:{name}Subcommand(a:line1, curwin && a:line2 < 0 ? 0 : a:line2, a:range, a:bang, a:mods, extend({'subcommand': args[0], 'subcommand_args': args[1:-1]}, options))
|
||||||
if type(overrides) == type('')
|
if type(overrides) == type('')
|
||||||
return 'exe ' . string(overrides) . after
|
return 'exe ' . string(overrides) . after
|
||||||
endif
|
endif
|
||||||
@@ -3406,10 +3407,10 @@ function! fugitive#Command(line1, line2, range, bang, mods, arg) abort
|
|||||||
let term_opts = len(env) ? {'env': env} : {}
|
let term_opts = len(env) ? {'env': env} : {}
|
||||||
if has('nvim')
|
if has('nvim')
|
||||||
call fugitive#Autowrite()
|
call fugitive#Autowrite()
|
||||||
return mods . (a:line2 ? 'new' : 'enew') . '|call termopen(' . string(argv) . ', ' . string(term_opts) . ')' . assign . '|startinsert' . after
|
return mods . (curwin ? 'enew' : 'new') . '|call termopen(' . string(argv) . ', ' . string(term_opts) . ')' . assign . '|startinsert' . after
|
||||||
elseif exists('*term_start')
|
elseif exists('*term_start')
|
||||||
call fugitive#Autowrite()
|
call fugitive#Autowrite()
|
||||||
if !a:line2
|
if curwin
|
||||||
let term_opts.curwin = 1
|
let term_opts.curwin = 1
|
||||||
endif
|
endif
|
||||||
return mods . 'call term_start(' . string(argv) . ', ' . string(term_opts) . ')' . assign . after
|
return mods . 'call term_start(' . string(argv) . ', ' . string(term_opts) . ')' . assign . after
|
||||||
@@ -3438,7 +3439,7 @@ function! fugitive#Command(line1, line2, range, bang, mods, arg) abort
|
|||||||
let [do_edit, after_edit] = s:ReadPrepare(a:line1, a:line2, a:range, a:mods)
|
let [do_edit, after_edit] = s:ReadPrepare(a:line1, a:line2, a:range, a:mods)
|
||||||
elseif pager is# 2 && a:bang
|
elseif pager is# 2 && a:bang
|
||||||
let do_edit = s:Mods(a:mods) . 'pedit'
|
let do_edit = s:Mods(a:mods) . 'pedit'
|
||||||
elseif a:line2
|
elseif !curwin
|
||||||
let do_edit = s:Mods(a:mods) . 'split'
|
let do_edit = s:Mods(a:mods) . 'split'
|
||||||
else
|
else
|
||||||
let do_edit = s:Mods(a:mods) . 'edit'
|
let do_edit = s:Mods(a:mods) . 'edit'
|
||||||
|
|||||||
Reference in New Issue
Block a user