For example: if (!iconNo.isNull()) { buttonNoGui.setIconName(iconNo); } if I toggle comment on the middle line (or all of them), it becomes: if (!iconNo.isNull()) { // buttonNoGui.setIconName(iconNo); } the // characters are added to the very beginning of the line; which works, but interferes with clang-format, which will then change that to: if (!iconNo.isNull()) { // buttonNoGui.setIconName(iconNo); } This can be avoided if the // characters are added like this to begin with: if (!iconNo.isNull()) { // buttonNoGui.setIconName(iconNo); }
Does it behave better if you pass the singleLine tag the position="afterwhitespace" attribute in the XML highlighting file?
(In reply to Christoph Cullmann from comment #1) > Does it behave better if you pass the singleLine tag the > position="afterwhitespace" attribute in the XML highlighting file? Yeah, that seems to have an effect: if (!iconNo.isNull()) { buttonNoGui.setIconName(iconNo); } becomes: if (!iconNo.isNull()) { //buttonNoGui.setIconName(iconNo); } but, of course, clang(pesky)-fromat still complains and changes it to: // buttonNoGui.setIconName(iconNo); so it would probably need another change in the indenter js code to add "// " instead of just "//". (I don't know javascript well enough to try hacking the indenter js code).
Git commit 178c4dfbf4eb5ad7c5aef4838f190f717f97766f by Ahmad Samir. Committed on 08/08/2022 at 21:30. Pushed by ahmadsamir into branch 'master'. clang-format.cmake: don't change spaces after '//' in code comments For example, if you have: //This is a comment now clang-format won't change it to: // This is a comment We're mainly interested in formatting the code, not the comments, so that cuts down on some noise when running clang-format. M +5 -0 kde-modules/clang-format.cmake https://invent.kde.org/frameworks/extra-cmake-modules/commit/178c4dfbf4eb5ad7c5aef4838f190f717f97766f
A possibly relevant merge request was started @ https://invent.kde.org/frameworks/extra-cmake-modules/-/merge_requests/289
A possibly relevant merge request was started @ https://invent.kde.org/frameworks/ktexteditor/-/merge_requests/397
Git commit fceb6fef10932a5b6aaf698c102f05bbed04e12a by Ahmad Samir. Committed on 10/08/2022 at 18:20. Pushed by cullmann into branch 'master'. KateDocument: always add space after single line comment start marker So that if you have code: if (foo) { do_something(); } commenting out the second line, it would become (assuming the position="afterwhitespace" option is set in c.xml): if (foo) { // do_something(); } This works better with clang-format, which insists on reformatting this: //do_something(); to // do_something(); to the version with the space, "// ". Fix unittests. M +1 -1 autotests/src/katedocument_test.cpp M +1 -2 src/document/katedocument.cpp https://invent.kde.org/frameworks/ktexteditor/commit/fceb6fef10932a5b6aaf698c102f05bbed04e12a
A possibly relevant merge request was started @ https://invent.kde.org/frameworks/syntax-highlighting/-/merge_requests/341
A possibly relevant merge request was started @ https://invent.kde.org/frameworks/ktexteditor/-/merge_requests/409
Git commit 93d6b7aebe7940cc63657f6d8df141fe02dee964 by Christoph Cullmann, on behalf of Waqar Ahmed. Committed on 25/08/2022 at 16:14. Pushed by cullmann into branch 'master'. Improve singleline selection commenting Currently, if you have a selection and "afterwhitespace" turned on for the language that you are using and you do a selection and comment it out it leads to a really bad result with languages like C/C++. Following code: ```c++ for (auto x : list) { if (x > 1) printf("%d", x); } ``` will become ```c++ // for (auto x : list) { // if (x > 1) // printf("%d", x); // } ``` Which makes zero sense. With this change, the comment marker will be placed at the smallest indent found in the selection, which can be 0. For the above code, the result will be: ```c++ // for (auto x : list) { // if (x > 1) // printf("%d", x); // } ``` Comments are nicely aligned, and we keep the indentation. This behaviour is consistent with other editors for e.g., vscode, sublime. Its also compatible with what for e.g clang-format or prettier do, i.e., align the comments according to indentation setting. Related: bug 438744 M +3 -3 autotests/src/katedocument_test.cpp M +44 -15 src/document/katedocument.cpp https://invent.kde.org/frameworks/ktexteditor/commit/93d6b7aebe7940cc63657f6d8df141fe02dee964
Git commit 656fbbcfd456f07bb7e1fc432cbe4ef6a16e0bcd by Waqar Ahmed. Committed on 25/08/2022 at 16:28. Pushed by waqar into branch 'master'. Change singleLineComments to be AfterWhiteSpace for c-like langs clang-format, the most commonly used formatter these days insists on comments being properly indented. Similarly other formatters like prettier also insist that comments are aligned. Related: bug 438744 M +1 -1 autotests/repository_test.cpp M +2 -2 data/syntax/c.xml M +2 -2 data/syntax/cpp.xml M +2 -2 data/syntax/cs.xml M +2 -2 data/syntax/d.xml M +2 -2 data/syntax/dart.xml M +2 -2 data/syntax/go.xml M +2 -2 data/syntax/isocpp.xml M +2 -2 data/syntax/java.xml M +2 -2 data/syntax/javascript.xml M +2 -2 data/syntax/php.xml M +2 -2 data/syntax/rust.xml M +2 -2 data/syntax/typescript.xml https://invent.kde.org/frameworks/syntax-highlighting/commit/656fbbcfd456f07bb7e1fc432cbe4ef6a16e0bcd