refactor KeyMap so we dont use index() on an array of objects
Dont do `remove(array_of_prototype_obs, index(...)))`. In the past this has been found to cause seg faults when the objects get large.
This commit is contained in:
parent
6782ec0104
commit
53bc77644c
@ -520,6 +520,15 @@ function! s:KeyMap.bind()
|
|||||||
exec 'nnoremap <buffer> <silent> '. mapkey . premap . ':call <SID>KeyMap_Invoke("'. self.key .'")<cr>'
|
exec 'nnoremap <buffer> <silent> '. mapkey . premap . ':call <SID>KeyMap_Invoke("'. self.key .'")<cr>'
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
"FUNCTION: KeyMap.Remove(key, scope) {{{3
|
||||||
|
function! s:KeyMap.Remove(key, scope)
|
||||||
|
let maps = s:KeyMap.All()
|
||||||
|
for i in range(len(maps))
|
||||||
|
if maps[i].key ==# a:key && maps[i].scope ==# a:scope
|
||||||
|
return remove(maps, i)
|
||||||
|
endif
|
||||||
|
endfor
|
||||||
|
endfunction
|
||||||
"FUNCTION: KeyMap.invoke() {{{3
|
"FUNCTION: KeyMap.invoke() {{{3
|
||||||
"Call the KeyMaps callback function
|
"Call the KeyMaps callback function
|
||||||
function! s:KeyMap.invoke(...)
|
function! s:KeyMap.invoke(...)
|
||||||
@ -606,11 +615,7 @@ endfunction
|
|||||||
|
|
||||||
"FUNCTION: KeyMap.Add(keymap) {{{3
|
"FUNCTION: KeyMap.Add(keymap) {{{3
|
||||||
function! s:KeyMap.Add(keymap)
|
function! s:KeyMap.Add(keymap)
|
||||||
let oldmap = s:KeyMap.FindFor(a:keymap.key, a:keymap.scope)
|
call s:KeyMap.Remove(a:keymap.key, a:keymap.scope)
|
||||||
if !empty(oldmap)
|
|
||||||
call remove(s:KeyMap.All(), index(s:KeyMap.All(), oldmap))
|
|
||||||
endif
|
|
||||||
|
|
||||||
call add(s:KeyMap.All(), a:keymap)
|
call add(s:KeyMap.All(), a:keymap)
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user