Overview -------- I forget the exact name of this feature, but when you declare a function or a member function in a header file and then partially type it in an implementation file, the editor will "magically" produce suggestions for autocompleting the declared function. In the old parser, this would replace the text you had already typed with the new completion. In the new parser, it ignores any text you have typed and just fills in the function, which in a lot of cases is just wrong. Steps to Reproduce ------------------ 1) Create a header file with the following content void Foo(int thing); struct Bar { void Method(int thing); }; 2) Create a .cpp file and type: "void Foo" 3) Wait, because the parser is now really slow 4) Finally, a suggestion for completing the "Foo" function pops up. Accept it. 5) Do the same for "Method" by typing "void Method" and accepting the completion. Actual Results -------------- The resulting completions ignore the already typed "void" keyword and simply insert the signatures, such that "void" now appears twice: void void Foo(int thing) { } void void Bar::Method(int thing) { } If a project wishes to format the return type such that it appears on a new line, then typing "void <new line> Foo" and accepting the suggestion produces this incorrect completion: void void Foo(int thing) { } An even worse example of this: 1) Begin typing "void Foo(int " 2) Press ctrl+space 3) Select "implement method Foo" 4) The completion creates this terrible snippet: Foo(int void Foo(int thing) { } ) Expected Results ---------------- The parser should be aware of the code that has already been typed and remove/adjust it as necessary. For the first example I expect the code to look like this after completion: void Foo(int thing) { } void Bar::Method(int thing) { } For the second example: void Foo(int thing) { } And for the third example: void Foo(int thing) { } Build Date & Platform --------------------- Ever since the clang based parser was introduced.
Yes, I've noticed this also; it's still a problem with the 5.2 branch.
I'm fairly sure I've seen this before 5.2, i.e. like always.
*** Bug 363057 has been marked as a duplicate of this bug. ***
*** Bug 385217 has been marked as a duplicate of this bug. ***
Git commit 4f2fc9e32452b3dc7f017d57c0bcc98b73cb0370 by Amish Naidu. Committed on 23/10/2018 at 07:54. Pushed by anaidu into branch 'master'. Replace leading typed text when completing function implementation Summary: When executing function-implementation auto-completion, this will now replace and leading typed text that matches the proposed completion instead of duplicating it. Test Plan: ``` int Foo(int thing); struct Bar { void Method(int thing); } ``` Start typing `int Foo` or `Bar::Meth` and then execute the offered completion. Reviewers: #kdevelop, mwolff Reviewed By: #kdevelop, mwolff Subscribers: kfunk, brauch, mwolff, apol, kdevelop-devel Tags: #kdevelop Differential Revision: https://phabricator.kde.org/D16326 M +6 -0 kdevplatform/language/duchain/stringhelpers.cpp M +5 -0 kdevplatform/language/duchain/stringhelpers.h M +16 -1 plugins/clang/codecompletion/context.cpp M +24 -0 plugins/clang/tests/test_codecompletion.cpp https://commits.kde.org/kdevelop/4f2fc9e32452b3dc7f017d57c0bcc98b73cb0370
Applies and builds in the 5.3 branch too. Can't yet say if it also has the desired effect but why wouldn't it... So thanks, it was quite annoying for a minor nuisance.