mirror of
https://github.com/preservim/tagbar.git
synced 2024-11-26 18:33:36 +08:00
Add protection for unknown kinds
Perform a has_key() check prior to referencing the dictionary to ensure the dictionary has a valid key for the specified kind. Note: When an unknown kind is found, it can mess up the tag highlighting in the tagbar window. Not sure why this is occurring.
This commit is contained in:
parent
98efae9899
commit
34a95983ed
|
@ -15,7 +15,8 @@ endfunction
|
|||
|
||||
" s:getKind() {{{1
|
||||
function! s:getKind(kind) abort dict
|
||||
let idx = self.kinddict[a:kind]
|
||||
"let idx = self.kinddict[a:kind]
|
||||
let idx = has_key(self.kinddict, a:kind) ? self.kinddict[a:kind] : -1
|
||||
return self.kinds[idx]
|
||||
endfunction
|
||||
|
||||
|
|
|
@ -21,6 +21,12 @@ endfunction
|
|||
function! s:compare_by_kind(tag1, tag2) abort
|
||||
let typeinfo = s:compare_typeinfo
|
||||
|
||||
if !has_key(typeinfo.kinddict, a:tag1.fields.kind)
|
||||
return -1
|
||||
endif
|
||||
if !has_key(typeinfo.kinddict, a:tag2.fields.kind)
|
||||
return 1
|
||||
endif
|
||||
if typeinfo.kinddict[a:tag1.fields.kind] <#
|
||||
\ typeinfo.kinddict[a:tag2.fields.kind]
|
||||
return -1
|
||||
|
|
Loading…
Reference in New Issue
Block a user