Skip to content

'PreviewSignature' does not work correctly with 'bang' #9

@chengzeyi

Description

@chengzeyi

In README.md, it was introduced:

Preview the function signature circularly in the command line:

PreviewSignature[!] [function name]
If the function name is not provided, current word under cursor will be taken as function name. 
If bang ! sign is given, the nearest function name to the cursor position is chosen.

But in the script, it was written:

function! s:PreviewSignature(bang, ...)
	let funcname = (a:0 > 0)? a:1 : ""
	if a:bang 
		let funcname = '<?>'
	endif
	call preview#function_echo(funcname, 0)
endfunc

Seems that with a bang given, the first argument passed to preview#function_echo() will be '<?>'. And preview#function_echo() is just a simple wrapper around preview#function_define() by passing its first parameter to it. But when I digged a little deeper into that function, I noticed the following lines, which a:name is indeed funcname occurring above:

if a:name == ''
	let name = preview#function_guess(line[0:endpos])
elseif a:name == '<?>'
	let name = expand('<cword>')
else
	let name = a:name
endif

Surprisingly, if a;name is '<?>', which is the circumstance we expect to have a 'guess' about the nearest function name by giving a bang adhering the 'PreviewSignature' command, what the function does is only picking the word under the cursor. However without a bang, an inner function called preview#function_guess() would try to guess the nearest function name. The command just behave conversely against the documentation.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions