mirror of
https://github.com/tpope/vim-fugitive.git
synced 2025-11-13 13:53:51 -05:00
Clean up argument splitting utility functions
This commit is contained in:
@@ -1192,17 +1192,16 @@ function! fugitive#Expand(object) abort
|
|||||||
\ '\=s:ExpandVar(submatch(1),submatch(2),submatch(3),submatch(5))', 'g')
|
\ '\=s:ExpandVar(submatch(1),submatch(2),submatch(3),submatch(5))', 'g')
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:ExpandSplit(string, ...) abort
|
function! s:SplitExpandChain(string, ...) abort
|
||||||
let list = []
|
let list = []
|
||||||
let string = a:string
|
let string = a:string
|
||||||
let handle_bar = a:0 && a:1
|
let dquote = '"\%([^"]\|""\|\\"\)*"\|'
|
||||||
let dquote = handle_bar ? '"\%([^"]\|""\|\\"\)*"\|' : ''
|
let cwd = a:0 ? a:1 : getcwd()
|
||||||
let cwd = a:0 > 1 ? a:2 : getcwd()
|
|
||||||
while string =~# '\S'
|
while string =~# '\S'
|
||||||
if handle_bar && string =~# '^\s*|'
|
if string =~# '^\s*|'
|
||||||
return [list, substitute(string, '^\s*', '', '')]
|
return [list, substitute(string, '^\s*', '', '')]
|
||||||
endif
|
endif
|
||||||
let arg = matchstr(string, '^\s*\%(' . dquote . '''[^'']*''\|\\.\|[^[:space:] ' . (handle_bar ? '|' : '') . ']\)\+')
|
let arg = matchstr(string, '^\s*\%(' . dquote . '''[^'']*''\|\\.\|[^[:space:] |]\)\+')
|
||||||
let string = strpart(string, len(arg))
|
let string = strpart(string, len(arg))
|
||||||
let arg = substitute(arg, '^\s\+', '', '')
|
let arg = substitute(arg, '^\s\+', '', '')
|
||||||
if !exists('seen_separator')
|
if !exists('seen_separator')
|
||||||
@@ -1217,15 +1216,7 @@ function! s:ExpandSplit(string, ...) abort
|
|||||||
let seen_separator = 1
|
let seen_separator = 1
|
||||||
endif
|
endif
|
||||||
endwhile
|
endwhile
|
||||||
return handle_bar ? [list, ''] : list
|
return [list, '']
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! s:SplitExpand(string, ...) abort
|
|
||||||
return s:ExpandSplit(a:string, 0, a:0 ? a:1 : getcwd())
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! s:SplitExpandChain(string, ...) abort
|
|
||||||
return s:ExpandSplit(a:string, 1, a:0 ? a:1 : getcwd())
|
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
let s:trees = {}
|
let s:trees = {}
|
||||||
@@ -4473,7 +4464,8 @@ function! fugitive#LogCommand(line1, count, range, bang, mods, args, type) abort
|
|||||||
let dir = s:Dir()
|
let dir = s:Dir()
|
||||||
exe s:DirCheck(dir)
|
exe s:DirCheck(dir)
|
||||||
let listnr = a:type =~# '^l' ? 0 : -1
|
let listnr = a:type =~# '^l' ? 0 : -1
|
||||||
let [args, after] = s:SplitExpandChain(a:args, s:Tree(dir))
|
let [args, after] = s:SplitExpandChain('log ' . a:args, s:Tree(dir))
|
||||||
|
call remove(args, 0)
|
||||||
let split = index(args, '--')
|
let split = index(args, '--')
|
||||||
if split > 0
|
if split > 0
|
||||||
let paths = args[split : -1]
|
let paths = args[split : -1]
|
||||||
|
|||||||
Reference in New Issue
Block a user