Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
chengzeyi opened this issue Aug 27, 2019 · 1 comment
Open

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

chengzeyi opened this issue Aug 27, 2019 · 1 comment

Comments

@chengzeyi
Copy link

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.

@chengzeyi
Copy link
Author

I suggest the easiest way to solve this problem is to correct README.md, while modification of the source code itself is not necessary :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant