Wrong indentation inside block comment
Closed this issue · 2 comments
Description
Wrong indentation inside block comment
Unformatted input snippet
foo () {
/*
typedef struct TEST {
DWORD cbSize; 0
} CMINVOKECOMMANDINFOEX;
*/
/*
MsgBox, This line is commented out (disabled).
MsgBox, Common mistake: */ this does not end the comment.
MsgBox, This line is commented out.
*/
/*
bar() {
Loop, 4 {
MsgBox % A_Index
}
if (true) {
SoundBeep
} else {
MsgBox
}
}
if (true)
ToolTip
*/
MsgBox
}
Expected formatted output snippet
foo () {
/*
typedef struct TEST {
DWORD cbSize; 0
} CMINVOKECOMMANDINFOEX;
*/
/*
MsgBox, This line is commented out (disabled).
MsgBox, Common mistake: */ this does not end the comment.
MsgBox, This line is commented out.
*/
/*
bar() {
Loop, 4 {
MsgBox % A_Index
}
if (true) {
SoundBeep
} else {
MsgBox
}
}
if (true)
ToolTip
*/
MsgBox
}
Actual formatted output snippet
foo () {
/*
typedef struct TEST {
DWORD cbSize; 0
} CMINVOKECOMMANDINFOEX;
*/
/*
MsgBox, This line is commented out (disabled).
MsgBox, Common mistake: */ this does not end the comment.
MsgBox, This line is commented out.
*/
/*
bar() {
Loop, 4 {
MsgBox % A_Index
}
if (true) {
SoundBeep
} else {
MsgBox
}
}
if (true)
ToolTip
*/
MsgBox
}
I'm not sure I would qualify this as a bug. What if the user wrote a block comment that isn't just code? In general, I believe formatters should leave comments as-is unless the user opts-in to modifications to the comments. The only default modification I'd support would be something like "indent comments the same level as their neighboring code":
; Input snippet
foo () {
; test
x = y
}
; Expected formatted snippet
foo () {
; test
x = y
}
Do you think this modification you are suggesting would be good if the block comments aren't commented code?
I wrote this issue for one of mine PR, now it's in WIP status. I propose add directive for formatter, for example ;@AHK++-FormatBlockComment
to enable this behavior for current block comment, and use syntax inside block comment like in real code, comment all text using ;
.