Summary: | Code completions turns . into -> for floating point number | ||
---|---|---|---|
Product: | [Applications] kdevelop | Reporter: | Benjamin Huth <benjamin-huth> |
Component: | Language Support: CPP (Clang-based) | Assignee: | kdevelop-bugs-null |
Status: | RESOLVED FIXED | ||
Severity: | minor | CC: | igorkuo, john-kde |
Priority: | NOR | ||
Version: | git master | ||
Target Milestone: | --- | ||
Platform: | Compiled Sources | ||
OS: | Linux | ||
See Also: | https://bugs.kde.org/show_bug.cgi?id=468605 | ||
Latest Commit: | https://invent.kde.org/kdevelop/kdevelop/commit/560c06ffb01dff577b58e3f2026ece17c49a0ed0 | Version Fixed In: | 5.11.230400 |
Attachments: | illustrating video |
Search for "->" (with quotes) in KDevelop source code. I think the relevant results are in MemberAccessReplacer::replaceCurrentAccess() in file plugins/clang/codecompletion/context.cpp. Other bugs about incorrect . to -> replacements have been reported. I've experienced such a bug myself a few years ago. Bug 432774 reports another wrong "." to "->" replacement. Git commit 560c06ffb01dff577b58e3f2026ece17c49a0ed0 by Benjamin Huth, on behalf of Benjamin Huth. Committed on 04/12/2022 at 11:26. Pushed by igorkushnir into branch 'master'. Code completion: Fix '.' to '->' for some cases There are some situations where KDevelop erroneously replaces a '.' with a '->', e.g. for floating point numbers some specific aggregate initializers. This fixes this (at least for some situations) by checking if clang reports a parse issue with a dot-to-arrow substitution. A new unit test is added to check the correct behaviour for the situation described in bug 460870. To check this, the code completion unit tests needed to be extended a bit: It is now possible to pass the expected code to the test that is then compared with the actual result. FIXED-IN: 5.11.230400 M +19 -4 plugins/clang/codecompletion/context.cpp M +69 -20 plugins/clang/tests/test_codecompletion.cpp https://invent.kde.org/kdevelop/kdevelop/commit/560c06ffb01dff577b58e3f2026ece17c49a0ed0 |
Created attachment 153129 [details] illustrating video SUMMARY In some rare circumstances, the code completion turns . into an ->, when typing floating point values without leading zero. I found this inside of aggregate initialization of a std::array, but did not check if there are other circumstances where this also happens. See also the attached video. A reproducible code example would be this: #include <array> struct S {double a, double b}; int main() { std::array<S, 1> a = {{ {0.6, /* here type a dot, and it will be converted to an arrow */ } }}; } If someone gives me a pointer where to start I'm willing to try fixing this myself. STEPS TO REPRODUCE 1. Put the code example in a cmake c++ project 2. try to type a floatingpoint number like .5 without leading 0 in the aggregate initializer OBSERVED RESULT code completion turns . into -> EXPECTED RESULT code completion does nothing SOFTWARE/OS VERSIONS Linux/KDE Plasma: Fedora 36 - Kernel 5.19 (available in About System) KDE Plasma Version: 5.25.5 KDE Frameworks Version: 5.99.0 Qt Version: 5.15.6