Bug 418918 - Comments by shortcut do not follow the indentation rule
Summary: Comments by shortcut do not follow the indentation rule
Status: RESOLVED FIXED
Alias: None
Product: kate
Classification: Applications
Component: indentation (other bugs)
Version First Reported In: Git
Platform: Compiled Sources Linux
: NOR normal
Target Milestone: ---
Assignee: KWrite Developers
URL:
Keywords:
: 429093 (view as bug list)
Depends on:
Blocks:
 
Reported: 2020-03-16 13:08 UTC by kogiokkafrms
Modified: 2023-01-21 13:59 UTC (History)
5 users (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments
Fixed in main (133.71 KB, image/gif)
2023-01-21 13:45 UTC, igormontagner
Details

Note You need to log in before you can comment on or make changes to this bug.
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