Sysprogs forums › Forums › VisualGDB › Clang Intellisense C++ comments
- This topic has 3 replies, 2 voices, and was last updated 4 years, 1 month ago by support.
-
AuthorPosts
-
October 21, 2020 at 12:40 #29328curtis.hendrixParticipant
Clang Intellisense auto-formatter does not play nice with C++ comments that are on the same line as code and have a space in between the code and comment.
This is with VisualGDB Version 5.5 (Preview 7, build 3666)
For example this code will remain the same after the auto-formatter is run with Clang Intellisense turned on:
if (uart_rx_byte_count == 0)// For the first byte received, the start byte must be 0x89
Note there is no space between the code and comment.
However, this line will always get a space added by the auto-formatter when it is run:
if (uart_rx_byte_count == 0) // For the first byte received, the start byte must be 0x89
The line will become something like this after the auto-formater is run enough times:
if (uart_rx_byte_count == 0) // For the first byte received, the start byte must be 0x89
In addition, the autoformatter will automatically double indent any blocks where there is a space and a comment before the braces. For example, this:
if (uart_rx_byte_count == 0) // For the first byte received, the start byte must be 0x89
{
if (data != 0x89) //Some comment
{
return;
}
}
will become this:
if (uart_rx_byte_count == 0) // For the first byte received, the start byte must be 0x89
{
if (data != 0x89) //Some comment
{
return;
}
}
HOWEVER, this:
if (uart_rx_byte_count == 0)// For the first byte received, the start byte must be 0x89
{
if (data != 0x89)//Some comment
{
return;
}
}
will remain the same. Note how there is not a space in between the closing parenthesis and the start of the comment.
This only happens with c++ comments (those that start with “//”). C-style comments (“/**/”) do not cause this behavior.
October 21, 2020 at 12:45 #29329supportKeymasterHi,
The recent version of VisualGDB would use the clang-format engine to format the code (including the comments). Clang-format could be tuned in numerous of ways by editing the .clang-format files (VisualGDB provides a graphical editor for them). Please see this page for an explanation how clang-format is integrated into VisualGDB and this page for an overview of clang-format options.
October 21, 2020 at 13:08 #29345curtis.hendrixParticipantIf the “Format” button is not shown, the currently open file is not handled by Clang-format and its formatting can be configured via Tools->Options->Text Editor->C/C++ (VisualGDB)->Formatting.
I don’t have the “Format” button, so the settings in Tools->Options…->Formatting should be getting applied. I’ve attached a screenshot of the settings. I don’t see where to disable automatically adding a space between code and comment every time the autoformatter is run, or how to disable double indenting when there’s a space in between comment and code for a control block.
I did find a work-around by enabling “Clang-format (advanced)”.
Attachments:
You must be logged in to view attached files.October 21, 2020 at 13:12 #29348supportKeymasterHi,
Good to know you have found a workaround.
As the clang-format integration works very well in most scenarios, we no longer add new settings to the legacy formatting engine and advise using clang-format if you would like to tweak parameters that are not available in the legacy engine.
-
AuthorPosts
- You must be logged in to reply to this topic.