clang_complete icon indicating copy to clipboard operation
clang_complete copied to clipboard

Inappropriate completion after "function("

Open xuhdev opened this issue 13 years ago • 6 comments

"strcmp(<C-X><C-U>" will lead to:

strcmp(strcmp(const_char_*__s1,_const_char_*__s2)

Only strcmp<C-X><C-U> could lead to the correct result.

I think this should be a bug, or at least need to be enhanced.

Thanks, this is a really great plugin.

xuhdev avatar Dec 15 '11 03:12 xuhdev

Hi,

Thanks for the report, this is actually a regression, it used to work as expected.

xavierd avatar Dec 18 '11 18:12 xavierd

I'll wait for the fix, and very willing to be helpful.

xuhdev avatar Dec 19 '11 05:12 xuhdev

Will this be fixed some day?

xuhdev avatar Jan 11 '12 14:01 xuhdev

Apparently, no one has enough free time for that. So I'm writing this just in case you (or someone else) have time and will to fix it, but don't know how to start. The reason of the issue is in ClangComplete() function, where an open parenthesis is threated specially so that a:base during next call is empty and completion is performed right after strcmp(, which isn't correct. Just adding ( to a:base by correcting return value on first call won't fix the issue, because filtering of completion results should be updated too. See https://gist.github.com/1596499 for a very crude example of how it might be fixed.

xaizek avatar Jan 11 '12 20:01 xaizek

The given link does not fix this problem at all. Could you give an explanation that what should a:base like in this completion? should it be 'strcmp('? I do not understand why you append a '$' in the gist.

Thanks.

xuhdev avatar Jan 16 '12 05:01 xuhdev

Strange, that changes fixed the problem for me at least partially (it was just to figure out the problematic place, so no surprise it doesn't always work correct). The issue is caused by an invalid filtering of completion results, with an empty string as completion beginning (so all of completion results match). For it to work a:base should be strcmp( during second call, but strcmp( wont work with libclang (I didn't try clang executable) because filtering is performed by the first element of the strings array returned by libclang (see getAbbr() function in libclang.py and also line 261). I added $ just because if we complete strcmp( we shouldn't get strcmpfoobar as a match, which is possible after ( is removed.

xaizek avatar Jan 16 '12 18:01 xaizek