Add linenr protection into getPrototype (#707)

* Add linenr protection into getPrototype
Closes #706

Add protection to not go beyond the last line in the file when calling the `s:getPrototype()` routine. This occurs when there is an `=` character in the tag prototype. For example in a python tag with a parameter line this: `some_function(arg1, optional_arg_2=False)`

* Fix issue with python prototypes that can include `=` character in the argument list
This commit is contained in:
raven42 2020-11-10 07:49:36 -06:00 committed by GitHub
parent 53c8e19676
commit 10a4a9bc38
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -86,7 +86,10 @@ function! s:getPrototype(short) abort dict
let line = getbufline(bufnr, self.fields.line)[0]
" If prototype includes declaration, remove the '=' and anything after
let line = substitute(line, '\s*=.*', '', '')
" FIXME: Need to remove this code. This breaks python prototypes that
" can include a '=' in the function paramter list.
" ex: function(arg1, optional_arg2=False)
" let line = substitute(line, '\s*=.*', '', '')
let list = split(line, '\zs')
let start = index(list, '(')
@ -104,7 +107,7 @@ function! s:getPrototype(short) abort dict
let prototype = line
let curlinenr = self.fields.line + 1
while balance > 0
while balance > 0 && curlinenr < line('$')
let curline = getbufline(bufnr, curlinenr)[0]
let curlist = split(curline, '\zs')
let balance += count(curlist, '(')