Avoid error when mapcheck() and <unique> semantics differ

References: https://github.com/tpope/vim-fugitive/issues/1826
This commit is contained in:
Tim Pope
2021-09-05 10:00:39 -04:00
parent 8d25dd777c
commit 0840f001fe

View File

@@ -219,7 +219,7 @@ function! s:Map(mode, lhs, rhs, ...) abort
let head = substitute(head, '<[^<>]*>$\|.$', '', '')
endwhile
if !skip && (flags !~# '<unique>' || empty(mapcheck(head.tail, mode)))
call add(maps, mode.'map <buffer>' . s:nowait . flags . ' ' . head.tail . ' ' . a:rhs)
call add(maps, mode.'map <buffer>' . s:nowait . substitute(flags, '<unique>', '', '') . ' ' . head.tail . ' ' . a:rhs)
if a:0 > 1
let b:undo_ftplugin = get(b:, 'undo_ftplugin', 'exe') .
\ '|sil! exe "' . mode . 'unmap <buffer> ' . head.tail . '"'