https://bugs.kde.org/show_bug.cgi?id=475921
Bug ID: 475921 Summary: Clang Format custom script formatter fails when includes violate the style-defined order Classification: Applications Product: kdevelop Version: 5.12.230802 Platform: Archlinux OS: Linux Status: REPORTED Severity: normal Priority: NOR Component: Language Support: CPP (Clang-based) Assignee: kdevelop-bugs-n...@kde.org Reporter: shlyonskikh.ale...@gmail.com Target Milestone: --- Created attachment 162474 --> https://bugs.kde.org/attachment.cgi?id=162474&action=edit Example file where formatting fails When using Clang Format custom script formatter, Kdevelop fails to format lines that follow lines starting with "#include" if they are ordered in a way that violates the order defined by clang-format's style. STEPS TO REPRODUCE 1. Use a clang-format style that enforces the order of #includes (for example, by including "BasedOnStyle: Google" in .clang-format in the project's directory) 2. Try to format some but not all lines in a file in which the order of #includes is violated (for example, line 11 in the attached file) OBSERVED RESULT No formatting takes place. If the order-violating lines precede the formatted lines, a "problem matching the left context" error message is displayed in the terminal. If the order-violating lines are included in the formatted lines, but the whole file is not formatted, a "problem matching the text while formatting" error message is displayed. EXPECTED RESULT Selected lines are formatted according to clang-format's output. ADDITIONAL INFORMATION The cause is likely the KDevelop::extractFormattedTextFromContext function from kdevplatform/util/formattinghelpers.cpp file, called from plugins/customscript/customscript_plugin.cpp . The text matching done there fails to match parts of the file when its lines have been switched around. -- You are receiving this mail because: You are watching all bug changes.