Make handling of '<>' notation more robust.

Previous case could fail with something like '<Tab><Tab>'.  Cases like
that should be handled correctly now.
This commit is contained in:
Chris Perl 2012-01-27 00:12:33 -05:00
parent 7fbb77c067
commit 30cc73d6ed

View File

@ -510,11 +510,14 @@ endfunction
"FUNCTION: KeyMap.bind() {{{3 "FUNCTION: KeyMap.bind() {{{3
function! s:KeyMap.bind() function! s:KeyMap.bind()
" If the key we're trying to map is a special key we must escape the " If the key sequence we're trying to map contains any '<>' notation, we
" leading '<', otherwise vim will replace it with the actual keycode " must replace each of the '<' characters with '<lt>' to ensure the string
" is not translated into its corresponding keycode during the later part
" of the map command below
" :he <> " :he <>
if self.key =~# '^<' let specialNotationRegex = '\m<\([[:alnum:]_-]\+>\)'
let keymapInvokeString = substitute(self.key, '^<', '<lt>', '') if self.key =~# specialNotationRegex
let keymapInvokeString = substitute(self.key, specialNotationRegex, '<lt>\1', 'g')
else else
let keymapInvokeString = self.key let keymapInvokeString = self.key
endif endif