codemaid
codemaid copied to clipboard
[Bug] Inserting a space before a single line comment
Environment
- Visual Studio version: 2022
- CodeMaid version: 12.0
- Code language: C#
Description
I enable: Inserting a space before a single line comment
, For the most part it works fine, but if I use the Kernighan & Ritchie curly bracket style, it produces an unnecessary blank line.
Current behavior
SomeEvent += (s, e) => {
// comment
Console.WriteLine("Some code here");
}
Expected behavior
SomeEvent += (s, e) => {
// comment
Console.WriteLine("Some code here");
}
Thanks for reporting the issue, I have been able to reproduce it. We have a regular expression that is used to try and capture the preceding brace exception, and I suspect it isn't covering this scenario.
https://github.com/codecadwallader/codemaid/blob/dev/CodeMaidShared/Logic/Cleaning/InsertBlankLinePaddingLogic.cs#L297
@codecadwallader Here's the solution from chatGPT, I haven't done much testing so just FYI:.
(^[ \t]*(?!//)[^ \t\r\n\{].*(?<!\{)\r?\n)([ \t]*//)(?!//)(?![ \t]*\})