mirror of
https://github.com/tpope/vim-fugitive.git
synced 2025-11-10 12:33:46 -05:00
Tiny optimization to s:Slash()
References https://github.com/tpope/vim-fugitive/issues/1701
This commit is contained in:
@@ -101,13 +101,15 @@ function! s:Mods(mods, ...) abort
|
|||||||
return substitute(mods, '\s\+', ' ', 'g')
|
return substitute(mods, '\s\+', ' ', 'g')
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:Slash(path) abort
|
if exists('+shellslash')
|
||||||
if exists('+shellslash')
|
function! s:Slash(path) abort
|
||||||
return tr(a:path, '\', '/')
|
return tr(a:path, '\', '/')
|
||||||
else
|
endfunction
|
||||||
|
else
|
||||||
|
function! s:Slash(path) abort
|
||||||
return a:path
|
return a:path
|
||||||
endif
|
endfunction
|
||||||
endfunction
|
endif
|
||||||
|
|
||||||
function! s:Resolve(path) abort
|
function! s:Resolve(path) abort
|
||||||
let path = resolve(a:path)
|
let path = resolve(a:path)
|
||||||
@@ -936,9 +938,11 @@ function! fugitive#Find(object, ...) abort
|
|||||||
let prefix = matchstr(a:object, '^[~$]\i*')
|
let prefix = matchstr(a:object, '^[~$]\i*')
|
||||||
let owner = expand(prefix)
|
let owner = expand(prefix)
|
||||||
return FugitiveVimPath((len(owner) ? owner : prefix) . strpart(a:object, len(prefix)))
|
return FugitiveVimPath((len(owner) ? owner : prefix) . strpart(a:object, len(prefix)))
|
||||||
elseif s:Slash(a:object) =~# '^$\|^/\|^\%(\a\a\+:\).*\%(//\|::\)' . (has('win32') ? '\|^\a:/' : '')
|
endif
|
||||||
|
let rev = s:Slash(a:object)
|
||||||
|
if rev =~# '^$\|^/\|^\%(\a\a\+:\).*\%(//\|::\)' . (has('win32') ? '\|^\a:/' : '')
|
||||||
return FugitiveVimPath(a:object)
|
return FugitiveVimPath(a:object)
|
||||||
elseif s:Slash(a:object) =~# '^\.\.\=\%(/\|$\)'
|
elseif rev =~# '^\.\.\=\%(/\|$\)'
|
||||||
return FugitiveVimPath(simplify(getcwd() . '/' . a:object))
|
return FugitiveVimPath(simplify(getcwd() . '/' . a:object))
|
||||||
endif
|
endif
|
||||||
let dir = a:0 ? a:1 : s:Dir()
|
let dir = a:0 ? a:1 : s:Dir()
|
||||||
@@ -949,7 +953,6 @@ function! fugitive#Find(object, ...) abort
|
|||||||
return fnamemodify(FugitiveVimPath(len(file) ? file : a:object), ':p')
|
return fnamemodify(FugitiveVimPath(len(file) ? file : a:object), ':p')
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
let rev = s:Slash(a:object)
|
|
||||||
let tree = s:Tree(dir)
|
let tree = s:Tree(dir)
|
||||||
let base = len(tree) ? tree : 'fugitive://' . dir . '//0'
|
let base = len(tree) ? tree : 'fugitive://' . dir . '//0'
|
||||||
if rev ==# '.git'
|
if rev ==# '.git'
|
||||||
|
|||||||
@@ -310,13 +310,15 @@ function! FugitiveGitPath(path) abort
|
|||||||
return s:Slash(a:path)
|
return s:Slash(a:path)
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:Slash(path) abort
|
if exists('+shellslash')
|
||||||
if exists('+shellslash')
|
function! s:Slash(path) abort
|
||||||
return tr(a:path, '\', '/')
|
return tr(a:path, '\', '/')
|
||||||
else
|
endfunction
|
||||||
|
else
|
||||||
|
function! s:Slash(path) abort
|
||||||
return a:path
|
return a:path
|
||||||
endif
|
endfunction
|
||||||
endfunction
|
endif
|
||||||
|
|
||||||
function! s:ProjectionistDetect() abort
|
function! s:ProjectionistDetect() abort
|
||||||
let file = s:Slash(get(g:, 'projectionist_file', ''))
|
let file = s:Slash(get(g:, 'projectionist_file', ''))
|
||||||
|
|||||||
Reference in New Issue
Block a user