mirror of
https://github.com/tpope/vim-fugitive.git
synced 2025-11-08 11:33:47 -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')
|
||||
endfunction
|
||||
|
||||
function! s:Slash(path) abort
|
||||
if exists('+shellslash')
|
||||
if exists('+shellslash')
|
||||
function! s:Slash(path) abort
|
||||
return tr(a:path, '\', '/')
|
||||
else
|
||||
endfunction
|
||||
else
|
||||
function! s:Slash(path) abort
|
||||
return a:path
|
||||
endif
|
||||
endfunction
|
||||
endfunction
|
||||
endif
|
||||
|
||||
function! s:Resolve(path) abort
|
||||
let path = resolve(a:path)
|
||||
@@ -936,9 +938,11 @@ function! fugitive#Find(object, ...) abort
|
||||
let prefix = matchstr(a:object, '^[~$]\i*')
|
||||
let owner = expand(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)
|
||||
elseif s:Slash(a:object) =~# '^\.\.\=\%(/\|$\)'
|
||||
elseif rev =~# '^\.\.\=\%(/\|$\)'
|
||||
return FugitiveVimPath(simplify(getcwd() . '/' . a:object))
|
||||
endif
|
||||
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')
|
||||
endif
|
||||
endif
|
||||
let rev = s:Slash(a:object)
|
||||
let tree = s:Tree(dir)
|
||||
let base = len(tree) ? tree : 'fugitive://' . dir . '//0'
|
||||
if rev ==# '.git'
|
||||
|
||||
@@ -310,13 +310,15 @@ function! FugitiveGitPath(path) abort
|
||||
return s:Slash(a:path)
|
||||
endfunction
|
||||
|
||||
function! s:Slash(path) abort
|
||||
if exists('+shellslash')
|
||||
if exists('+shellslash')
|
||||
function! s:Slash(path) abort
|
||||
return tr(a:path, '\', '/')
|
||||
else
|
||||
endfunction
|
||||
else
|
||||
function! s:Slash(path) abort
|
||||
return a:path
|
||||
endif
|
||||
endfunction
|
||||
endfunction
|
||||
endif
|
||||
|
||||
function! s:ProjectionistDetect() abort
|
||||
let file = s:Slash(get(g:, 'projectionist_file', ''))
|
||||
|
||||
Reference in New Issue
Block a user