mirror of
https://github.com/tpope/vim-fugitive.git
synced 2025-11-12 21:33:53 -05:00
Fix edge case in s:Map() short circuiting
When called with multiple modes, don't bail after the first disabled mode. This also restructures in a way to allow for transition to :exe s:Map(), which will provide the correct line number on :verbose map <whatever>.
This commit is contained in:
@@ -199,33 +199,35 @@ endfunction
|
|||||||
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, ...) abort
|
||||||
|
let maps = []
|
||||||
for mode in split(a:mode, '\zs')
|
for mode in split(a:mode, '\zs')
|
||||||
|
let skip = 0
|
||||||
let flags = (a:0 ? a:1 : '') . (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:, mode.'remap', {})
|
||||||
if type(keys) == type([])
|
if type(keys) == type([])
|
||||||
return
|
continue
|
||||||
endif
|
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]
|
||||||
if empty(head)
|
let skip = empty(head)
|
||||||
return
|
|
||||||
endif
|
|
||||||
break
|
break
|
||||||
endif
|
endif
|
||||||
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))
|
if !skip && flags !~# '<unique>' || empty(mapcheck(head.tail, mode))
|
||||||
exe mode.'map <buffer>' s:nowait flags head.tail a:rhs
|
call add(maps, mode.'map <buffer>' . s:nowait . flags . ' ' . head.tail . ' ' . a:rhs)
|
||||||
if a:0 > 1
|
if a:0 > 1
|
||||||
let b:undo_ftplugin = get(b:, 'undo_ftplugin', 'exe') .
|
let b:undo_ftplugin = get(b:, 'undo_ftplugin', 'exe') .
|
||||||
\ '|sil! exe "' . mode . 'unmap <buffer> ' . head.tail . '"'
|
\ '|sil! exe "' . mode . 'unmap <buffer> ' . head.tail . '"'
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
endfor
|
endfor
|
||||||
|
exe join(maps, '|')
|
||||||
|
return ''
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! fugitive#Autowrite() abort
|
function! fugitive#Autowrite() abort
|
||||||
@@ -7210,9 +7212,12 @@ function! s:NavigateUp(count) abort
|
|||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:MapMotion(lhs, rhs) abort
|
function! s:MapMotion(lhs, rhs) abort
|
||||||
call s:Map('n', a:lhs, ":<C-U>" . a:rhs . "<CR>", "<silent>")
|
let maps = [
|
||||||
call s:Map('o', a:lhs, ":<C-U>" . a:rhs . "<CR>", "<silent>")
|
\ s:Map('n', a:lhs, ":<C-U>" . a:rhs . "<CR>", "<silent>"),
|
||||||
call s:Map('x', a:lhs, ":<C-U>exe 'normal! gv'<Bar>" . a:rhs . "<CR>", "<silent>")
|
\ s:Map('o', a:lhs, ":<C-U>" . a:rhs . "<CR>", "<silent>"),
|
||||||
|
\ s:Map('x', a:lhs, ":<C-U>exe 'normal! gv'<Bar>" . a:rhs . "<CR>", "<silent>")]
|
||||||
|
call filter(maps, '!empty(v:val)')
|
||||||
|
return join(maps, '|')
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! fugitive#MapJumps(...) abort
|
function! fugitive#MapJumps(...) abort
|
||||||
|
|||||||
Reference in New Issue
Block a user