Summary: | Feature request: Let indentation be indentation when outcommenting lines | ||
---|---|---|---|
Product: | [Applications] kate | Reporter: | Andreas Nordal <andreas_nordal_4> |
Component: | part | Assignee: | KWrite Developers <kwrite-bugs-null> |
Status: | RESOLVED FIXED | ||
Severity: | wishlist | CC: | nate, waqar.17a |
Priority: | NOR | ||
Version: | 21.04.1 | ||
Target Milestone: | --- | ||
Platform: | Other | ||
OS: | Linux | ||
Latest Commit: | https://invent.kde.org/frameworks/syntax-highlighting/commit/656fbbcfd456f07bb7e1fc432cbe4ef6a16e0bcd | Version Fixed In: |
Description
Andreas Nordal
2021-06-16 15:03:07 UTC
A possibly relevant merge request was started @ https://invent.kde.org/frameworks/syntax-highlighting/-/merge_requests/341 I think providing this as default is not a good idea, see the linked MR. However, if you want, you can change it for yourself. See the linked MR for required changes and "Syntax Highlighting" docs. You can just copy the xml file locally and modify the comment mode. 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 456819 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 456819 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 |