Skip to content

Commit

Permalink
Fix funcname() for Vim 7.4.1608
Browse files Browse the repository at this point in the history
  • Loading branch information
thinca committed Mar 21, 2016
1 parent e1aeee1 commit 80f1ee4
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
14 changes: 13 additions & 1 deletion autoload/themis/util.vim
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,19 @@ function! themis#util#is_funcname(name) abort
endfunction

function! themis#util#funcname(funcref) abort
return matchstr(string(a:funcref), '^function(''\zs.*\ze'')$')
if has('patch-7.4.1608')
" From Vim 7.4.1608, the result of string() with Partial
" (a kind of Funcref) contains {arglist} and {self} as follows
"
" function('100', [1], {'method': function('100')})
"
" E724 occurs if the {arglist} or {self} contains a circular reference
" Ignore this error with :silent!
silent! let str = string(function(a:funcref, {}))
else
let str = string(a:funcref)
endif
return matchstr(str, '^function(''\zs[^'']\{-}\ze''')
endfunction

function! themis#util#get_full_title(obj, ...) abort
Expand Down
2 changes: 1 addition & 1 deletion test/util.vimspec
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ Describe util
let obj = {}
function! obj.func() abort
endfunction
let funcname = matchstr(string(obj.func), 'function(''\zs.\{-}\ze'')')
let funcname = matchstr(string(obj.func), '^function(''\zs[^'']\{-}\ze''')
unlet obj
Assert False(themis#util#funcdata(funcname).exists)
End
Expand Down

0 comments on commit 80f1ee4

Please sign in to comment.