Hovering over `#include "foo.h"` will open a tooltip with a link to open foo.h ; not so when there's whitespace after the hash (`# include "foo.h"`). Both are valid syntax; is this difference in behaviour a bug or a feature?
a bug, patches welcome
Any suggestions where to start looking for the source of this bug? I'd search for "#include" but somehow I think that won't be of much help :) (including the quotes actually gives only a single hit, in the astyle plugin).
I think those are the spots you should look at: ``` % ag -s ClangUtils::rangeForIncludePathSpec plugins/clang/clangsupport.cpp 102: KTextEditor::Range wordRange = ClangUtils::rangeForIncludePathSpec(line, pair.second); plugins/clang/util/clangutils.cpp 79:KTextEditor::Range ClangUtils::rangeForIncludePathSpec(const QString& line, const KTextEditor::Range& originalRange) plugins/clang/tests/test_clangutils.cpp 273: QCOMPARE(ClangUtils::rangeForIncludePathSpec("#include <vector>"), KTextEditor::Range(0, 10, 0, 16)); 274: QCOMPARE(ClangUtils::rangeForIncludePathSpec("#include <foo\\\".h>"), KTextEditor::Range(0, 10, 0, 17)); 275: QCOMPARE(ClangUtils::rangeForIncludePathSpec("#include \"foo\\\".h\""), KTextEditor::Range(0, 10, 0, 17)); 276: QCOMPARE(ClangUtils::rangeForIncludePathSpec("#include \"foo<>.h\""), KTextEditor::Range(0, 10, 0, 17)); ```
Can it really be so simple to fix? https://phabricator.kde.org/D12903
Git commit 06cbebf36cfa39388430d7043197189b2e54a5d2 by Kevin Funk, on behalf of René J.V. Bertin. Committed on 16/05/2018 at 07:28. Pushed by kfunk into branch '5.2'. KDevelop : support whitespace between the '#' and 'include' (or 'import') Summary: The C/C++ parser fails to recognise include statements where the hash symbol has whitespace between it and the include/import command. This patch fixes that. FIXED-IN: 5.2.2 Test Plan: Works as expected. Reviewers: #kdevelop, antonanikin, kfunk Reviewed By: #kdevelop, antonanikin, kfunk Subscribers: kfunk, kdevelop-devel Tags: #kdevelop Differential Revision: https://phabricator.kde.org/D12903 M +2 -0 plugins/clang/tests/test_clangutils.cpp M +1 -1 plugins/clang/util/clangutils.cpp https://commits.kde.org/kdevelop/06cbebf36cfa39388430d7043197189b2e54a5d2