clang_complete
clang_complete copied to clipboard
Inappropriate completion after "function("
"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.
Hi,
Thanks for the report, this is actually a regression, it used to work as expected.
I'll wait for the fix, and very willing to be helpful.
Will this be fixed some day?
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.
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.
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.