mirror of
https://github.com/tpope/vim-fugitive.git
synced 2025-11-16 15:23:51 -05:00
Minor performance improvement to global map definition
This commit is contained in:
@@ -660,15 +660,12 @@ endif
|
|||||||
|
|
||||||
let s:nowait = v:version >= 704 ? '<nowait>' : ''
|
let s:nowait = v:version >= 704 ? '<nowait>' : ''
|
||||||
|
|
||||||
function! s:Map(mode, lhs, rhs, ...) abort
|
function! s:Map(mode, lhs, rhs, flags) abort
|
||||||
for mode in split(a:mode, '\zs')
|
let flags = a:flags . (a:rhs =~# '<Plug>' ? '' : '<script>')
|
||||||
let flags = (a:0 ? a:1 : '') . (a:rhs =~# '<Plug>' ? '' : '<script>')
|
|
||||||
let head = a:lhs
|
let head = a:lhs
|
||||||
let tail = ''
|
let tail = ''
|
||||||
let keys = get(g:, mode.'remap', {})
|
let keys = get(g:, a:mode.'remap', {})
|
||||||
if type(keys) == type([])
|
if len(keys) && type(keys) == type({})
|
||||||
return
|
|
||||||
endif
|
|
||||||
while !empty(head)
|
while !empty(head)
|
||||||
if has_key(keys, head)
|
if has_key(keys, head)
|
||||||
let head = keys[head]
|
let head = keys[head]
|
||||||
@@ -680,10 +677,10 @@ function! s:Map(mode, lhs, rhs, ...) abort
|
|||||||
let tail = matchstr(head, '<[^<>]*>$\|.$') . tail
|
let tail = matchstr(head, '<[^<>]*>$\|.$') . tail
|
||||||
let head = substitute(head, '<[^<>]*>$\|.$', '', '')
|
let head = substitute(head, '<[^<>]*>$\|.$', '', '')
|
||||||
endwhile
|
endwhile
|
||||||
if flags !~# '<unique>' || empty(mapcheck(head.tail, mode))
|
|
||||||
exe mode.'map' s:nowait flags head.tail a:rhs
|
|
||||||
endif
|
endif
|
||||||
endfor
|
if flags !~# '<unique>' || empty(mapcheck(head.tail, a:mode))
|
||||||
|
exe a:mode.'map' s:nowait flags head.tail a:rhs
|
||||||
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
call s:Map('c', '<C-R><C-G>', 'fnameescape(fugitive#Object(@%))', '<expr>')
|
call s:Map('c', '<C-R><C-G>', 'fnameescape(fugitive#Object(@%))', '<expr>')
|
||||||
|
|||||||
Reference in New Issue
Block a user