motiejus/dotfiles

Unnamed repository; edit this file 'description' to name the repository.
git clone https://git.jakstys.lt/motiejus/dotfiles.git
Log | Tree | Refs | README | LICENSE

commit f5bbd4eea077828340f6722dbc8a58847bd5784f (tree)
parent 3eb6f316c09553989e59bb3802da100a6fb7c091
Author: Tim Pope <code@tpope.net>
Date:   Tue, 16 Mar 2021 15:52:37 -0400

Tiny optimization to s:Slash()

References https://github.com/tpope/vim-fugitive/issues/1701

Diffstat:
Mautoload/fugitive.vim | 19+++++++++++--------
Mplugin/fugitive.vim | 12+++++++-----
2 files changed, 18 insertions(+), 13 deletions(-)

diff --git a/autoload/fugitive.vim b/autoload/fugitive.vim @@ -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' diff --git a/plugin/fugitive.vim b/plugin/fugitive.vim @@ -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', ''))