Bug 418918

Summary: Comments by shortcut do not follow the indentation rule
Product: [Applications] kate Reporter: kogiokkafrms
Component: indentationAssignee: KWrite Developers <kwrite-bugs-null>
Status: RESOLVED FIXED    
Severity: normal CC: igordsm, justin.zobel, kde.podagric, kogiokkafrms, waqar.17a
Priority: NOR    
Version First Reported In: Git   
Target Milestone: ---   
Platform: Compiled Sources   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:
Attachments: Fixed in main

Description kogiokkafrms 2020-03-16 13:08:41 UTC
SUMMARY
The starting point of comment syntax should be right after the indentation of the commented line. Currently Kate's comment shortcut (Ctrl+/) puts the comment syntax at the very beginning of the line, without regard to the indentation.

This bug will cause auto-formatting tools like clang-format to indent the commented line once again.

STEPS TO REPRODUCE
1. Example code:
main.cc
----
#include <iostream>
int
main()
{
  std::cout << "Hello World!" << std::endl;
  {
    std::cout << "Hello World!" << std::endl;
    {
      std::cout << "Hello World!" << std::endl;
    }
  }
}
----

2. Press Ctrl+/ to comment the hello-worlds.


OBSERVED RESULT

Indentations by Ctrl+/
<main.cc>
----
#include <iostream>
int
main()
{
//   std::cout << "Hello World!" << std::endl;
  {
//     std::cout << "Hello World!" << std::endl;
    {
//       std::cout << "Hello World!" << std::endl;
    }
  }
}
----

Result from "clang-format --style=Mozilla main.cc":
<main.cc>
----
#include <iostream>
int
main()
{
  //   std::cout << "Hello World!" << std::endl;
  {
    //     std::cout << "Hello World!" << std::endl;
    {
      //       std::cout << "Hello World!" << std::endl;
    }
  }
}
----


EXPECTED RESULT

Comments in respect of indentations:
<main.cc>
----
#include <iostream>
int
main()
{
  // std::cout << "Hello World!" << std::endl;
  {
    // std::cout << "Hello World!" << std::endl;
    {
      // std::cout << "Hello World!" << std::endl;
    }
  }
}
----

SOFTWARE/OS VERSIONS
Linux/KDE Plasma: Fedora
KDE Plasma Version: 5.17.5
KDE Frameworks Version: 5.67.0 
Qt Version: 5.13.2

ADDITIONAL INFORMATION
None
Comment 1 Justin Zobel 2020-10-27 09:01:23 UTC
Confirmed this is still an issue on git master.
Comment 2 Justin Zobel 2020-11-21 11:48:29 UTC
*** Bug 429093 has been marked as a duplicate of this bug. ***
Comment 3 igormontagner 2023-01-21 13:45:04 UTC
Created attachment 155470 [details]
Fixed in main

I tested this in main and it seems fixed.
Comment 4 Waqar Ahmed 2023-01-21 13:59:34 UTC
This was fixed with KSyntaxHighlighting 656fbbcfd456f07bb7e1fc432cbe4ef6a16e0bcd